npm: Laravel-Mix directory missing
Asked Answered
T

3

12

I'm trying to run npm run dev on a Laravel project, but I get the following error.

Error: Cannot find module '/home/faramarz/todo/node_modules/laravel-mix/setup/webpack.config.js'

And yes, there is no such file in the node-module/ dir. But I ran npm install with no problem. I also ran npm i laravel-mix, but it didn't install it.

package.json

{
"private": true,
"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
    "axios": "^0.17",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^5.2.0",
    "jquery": "^3.2",
    "laravel-mix": "^1.0",
    "lodash": "^4.17.4",
    "vue": "^2.5.7"
}

}

I always face this problem running this command. Any help?

npm -v:6.4.1

Timothytimour answered 31/8, 2018 at 18:22 Comment(1)
This might sound silly sometimes. But please make sure that you've everything spelled well. I had it named as wepack.mix.js in my lumen projectNephoscope
Y
27

Delete the node_module/ directory and run the following on the command line.

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

If that doesn't work, try:

npm install webpack --save
Yoshida answered 31/8, 2018 at 20:13 Comment(3)
@Faramarz Try running npm install --save-dev webpack-dev-server if that doesn't work try running node_modules/.bin/webpackYoshida
this time the error was a bit different: Error: spawn node_modules/webpack/bin/webpack.js ENOENTTimothytimour
@Faramarz I edited my answer. Try the following: rm -rf node_modules rm package-lock.json yarn.lock npm cache clear --force npm installYoshida
F
0

Remove space and '&' from your Directory name and reinstall npm.

Findley answered 20/8, 2023 at 14:21 Comment(0)
C
0

Use this command

npm install --force --legacy-peer-deps
npm run dev
Crippling answered 27/8, 2023 at 17:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.