Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm: Laravel-Mix directory missing

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

like image 459
Faramarz Avatar asked Aug 31 '18 18:08

Faramarz


1 Answers

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
like image 189
Polaris Avatar answered Dec 06 '22 03:12

Polaris