Laravel-mix: node_modules/laravel-mix/ folder is missing after npm install

Created on 6 Jun 2018  路  12Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: #.#.# (npm list --depth=0)
  • Node Version (node -v): 8.11.2
  • NPM Version (npm -v): 5.6.0
  • OS: virtualbox - ubuntu 18.04
    (I'm using XAMPP)

Description:

1

I'm getting the following error message when I try to run: "npm run dev"
Error: Cannot find module '/home/sedon/laravel-project/node_modules/laravel-mix/setup/webpack.config.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at requireConfig (/home/sedon/laravel-project/node_modules/webpack/bin/convert-argv.js:97:18)
at /home/sedon/laravel-project/node_modules/webpack/bin/convert-argv.js:104:17
at Array.forEach ()
at module.exports (/home/sedon/laravel-project/node_modules/webpack/bin/convert-argv.js:102:15)
at yargs.parse (/home/sedon/laravel-project/node_modules/webpack/bin/webpack.js:171:41)
at Object.Yargs.self.parse (/home/sedon/laravel-project/node_modules/yargs/yargs.js:533:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/sedon/.npm/_logs/2018-06-06T14_35_31_310Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: npm run development
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/sedon/.npm/_logs/2018-06-06T14_35_31_322Z-debug.log

2

I've read the description:
Note: You won't find a webpack.config.js file in your project root. By default, Laravel defers to the config file from this repo. However, should you need to configure it, you may copy the file to your project root, and then update your package.json NPM scripts accordingly: cp node_modules/laravel-mix/setup/webpack.config.js ./

~Unfortunately there is no node_modules/laravel-mix folder I could copy. I also tried to install laravel-mix following the description for a stand alone project:

mkdir my-app && cd my-app
npm init -y
npm install laravel-mix --save-dev
cp -r node_modules/laravel-mix/setup/webpack.mix.js ./

ERROR

npm install laravel-mix --save-dev and npm install (in laravel project using ubuntu-virtualbox-xampp) produce the same error:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: node lib/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/sedon/.npm/_logs/2018-06-06T14_52_30_349Z-debug.log

Steps To Reproduce:

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": "npm run development -- --watch",
"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.18",
"bootstrap": "^4.0.0",
"popper.js": "^1.12",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^2.0",
"lodash": "^4.17.4",
"vue": "^2.5.7"
}
}

Most helpful comment

Delete node_module directory and run below in command line
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

If still not working, try below
npm install webpack --save

All 12 comments

UPDATE!
If anyone experiences the same problem I downloaded Linux Mint and installed everything the same way I did in Ubuntu, it's okay now.

@SedonDave can you close this issue?

I don't know if the issues related but i get this error today with laravel-mix 2.0 and windows 10. Everything was working great and after deleting and reinstalling node modules i get this.

@ development C:\Users...............(the path)
cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"

The system cannot find the path specified.
events.js:167
throw er; // Unhandled 'error' event
^

Error: spawn node_modules\webpack\bin\webpack.js ENOENT

returning to laravel-mix 1.0 fixed the issue.

I'm getting the same error/problem as @SedonDave on a freshly spun-up Ubuntu 16.04 (PHP 7.2) server after running npm install.

Relevant portions of my package.json:

"dependencies": {}, "devDependencies": { "laravel-mix": "^2.1.11" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "watch": "NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "hot": "NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", "production": "NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" },

any update? same problem with lavarel version^2.1.14 on Window 10.

here is my package.json

{
    "author": "Anak Wannaphaschaiyong and Panupong Wongsupa",
    "description": "Nesvio store",
    "private": true,
    "scripts": {
        "dev": "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",
        "hot": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "dependencies": {
        "axios": "^0.18.0",
        "chart.js": "^2.7.2",
        "cross-env": "^5.2.0",
        "foundation-sites": "^6.5.0-rc.3",
        "jquery": "^3.3.1",
        "laravel-mix": "^1.0.0",
        "motion-ui": "^2.0.3",
        "npm": "^6.4.1",
        "slick-carousel": "^1.8.1",
        "vue": "^2.5.17"
    }
}

Sorry everyone, I don鈥檛 think it鈥檚 a Mix issue if the folder isn鈥檛 showing up when you run npm install. Check your node and npm versions and upgrade if possible.

I ran into the same issue today on Windows 10, and solved this issue removing node_modules and package.json.lock, and instead of using npm I used yarn, after that worked perfectly.

Delete node_module directory and run below in command line
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

If still not working, try below
npm install webpack --save

I dont know what was the issue but after trying to debug for more than 5 hours @mnshuhailey's solution worked for me. Thanks a lot

Thanks @mnshuhailey, after trying a lot of things your 4 steps helped me!

i got the same issue the way I resolve this issue was to delete node_module and package-lock-json file for directory and than do npm install, and i download an old version of laravel-mix that is npm i [email protected] and than after that i did npm audit fix and the issue was resolved...

I had the same issue, I resolve it by upgrading to v4.0

npm remove laravel-mix
npm install laravel-mix@^4.0.0 --save-dev

and following steps are same

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sdebacker picture sdebacker  路  3Comments

terion-name picture terion-name  路  3Comments

RomainGoncalves picture RomainGoncalves  路  3Comments

Micaso picture Micaso  路  3Comments

stefensuhat picture stefensuhat  路  3Comments