Laravel-mix: Outdated webpack.mix.js and package.json after fresh installation of Laravel 5.4.32 with Laravel Mix 1.0

Created on 4 Aug 2017  ·  22Comments  ·  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: #.#.# (npm list --depth=0) that command doesn't return anything after the fresh install of Laravel
  • Node Version (node -v): 6.11.2
  • NPM Version (npm -v): 4.2.0
  • OS: Ubuntu 16.04 / Homestead on Windows10

Description:

I receive the following outdated content in both webpack.mix.js and package.json when I make a fresh install (inside Homestead's Ubuntu) with the command below.
According to the instructions here the content should be very different: https://github.com/JeffreyWay/laravel-mix/blob/master/docs/installation.md

Steps To Reproduce:

Following the instructions here: https://laravel.com/docs/5.4 I just executed this command.

laravel new blog

webpack.mix.js

let mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');

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 --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.16.2",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^5.0.1",
    "jquery": "^3.1.1",
    "laravel-mix": "^1.0",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  }
}

Most helpful comment

@patlecat You seem to be experiencing issues related to faulty installs. Every error you've posted is related to something missing. It's tough to debug these sorts of things, because Mix specifically lists them as dependencies. So there's no code-related change I can make here.

Try to do a full reset:

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

All 22 comments

Did it throw any errors or warning?

This is not outdated. These are the settings inside of Laravel Framework and not from Laravel Mix. Do not get confused on this.

The package-lock.json that you saw is from https://github.com/laravel/laravel/blob/master/package.json

@ruchern Consider me officially and deeply confused now! So Laravel-Mix is not the same when it manages the setup inside of Laravel and uses different config files depending on where it's used? What?

And yes it throws errors for the same reason that you told me the last time to use the package.json from the https://github.com/JeffreyWay/laravel-mix/blob/master/docs/installation.md manual page!

vagrant@homestead:~/Code/Laravel$ npm run dev --no-bin-link

> @ dev /home/vagrant/Code/Laravel
> npm run development


> @ development /home/vagrant/Code/Laravel
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting

 ERROR  Failed to compile with 2 errors                                                                       9:57:17 AM

 error  in ./resources/assets/sass/app.scss

Module build failed: Error: ENOENT: no such file or directory, scandir '/home/vagrant/Code/Laravel/node_modules/node-sass/vendor'
    at Error (native)
    at Object.fs.readdirSync (fs.js:952:18)
    at Object.getInstalledBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/extensions.js:124:13)
    at foundBinariesList (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/binding.js:15:30)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/sass-loader/lib/loader.js:3:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)

 @ ./resources/assets/sass/app.scss 4:14-266
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

 error  in ./resources/assets/sass/app.scss

Module build failed: ModuleBuildError: Module build failed: Error: ENOENT: no such file or directory, scandir '/home/vagrant/Code/Laravel/node_modules/node-sass/vendor'
    at Error (native)
    at Object.fs.readdirSync (fs.js:952:18)
    at Object.getInstalledBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/extensions.js:124:13)
    at foundBinariesList (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/binding.js:15:30)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/sass-loader/lib/loader.js:3:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at runLoaders (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModule.js:194:19)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:170:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:27:11)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModule.js:181:3)
    at NormalModule.build (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModule.js:274:15)
    at Compilation.buildModule (/home/vagrant/Code/Laravel/node_modules/webpack/lib/Compilation.js:146:10)
    at moduleFactory.create (/home/vagrant/Code/Laravel/node_modules/webpack/lib/Compilation.js:433:9)
    at factory (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:241:5)
    at applyPluginsAsyncWaterfall (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:94:13)
    at /home/vagrant/Code/Laravel/node_modules/tapable/lib/Tapable.js:268:11
    at NormalModuleFactory.params.normalModuleFactory.plugin (/home/vagrant/Code/Laravel/node_modules/webpack/lib/CompatibilityPlugin.js:52:5)
    at NormalModuleFactory.applyPluginsAsyncWaterfall (/home/vagrant/Code/Laravel/node_modules/tapable/lib/Tapable.js:272:13)
    at resolver (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:69:10)
    at process.nextTick (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:194:7)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
                                                                                                                Asset     Size  Chunks                    Chunk Names
/js/app.js  1.21 MB       0  [emitted]  [big]  /js/app

npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "development"
npm ERR! node v6.11.2
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 2
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 2
npm ERR!
npm ERR! Failed at the @ development script '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! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     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! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/.npm/_logs/2017-08-04T09_57_18_158Z-debug.log

npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev" "--no-bin-link"
npm ERR! node v6.11.2
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ dev script 'npm run development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/.npm/_logs/2017-08-04T09_57_18_223Z-debug.log

From the log, I think your npm install resulted in missing packages.

@ruchern I don't know but this is a totally standard fresh installation with config files untouched as you wished it. It's reproducible.

@patlecat You seem to be experiencing issues related to faulty installs. Every error you've posted is related to something missing. It's tough to debug these sorts of things, because Mix specifically lists them as dependencies. So there's no code-related change I can make here.

Try to do a full reset:

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

@JeffreyWay The steps you listed worked fine for the "npm install", thank you. But they are not listed in the documentation, not even as problem solver hint. And shouldn't Mix install correctly out of the box on a fresh Laravel installation on Linux? And if I have those problems repeatedly with fresh installations following the documentation then it's reproducible and should be investigated. It may well be a problem on the side of node/npm or Webpack but as the last in the chain Mix should handle all of the underlying complexity for us, that was the idea wasn't it?

But then "npm run dev" failed again miserably complaining about the same cross-env lines again which @ruchern recommended to replace with the new one on this repo, but you said it's not necessary. As you can see cross-env is installed correctly.

vagrant@homestead:~/Code/Laravel$ npm list cross-env
/home/vagrant/Code/Laravel
└── [email protected]

vagrant@homestead:~/Code/Laravel$ npm run dev

> @ dev /home/vagrant/Code/Laravel
> npm run development


> @ development /home/vagrant/Code/Laravel
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting

 ERROR  Failed to compile with 2 errors                                                                       8:05:41 AM

 error  in ./resources/assets/sass/app.scss

Module build failed: Error: ENOENT: no such file or directory, scandir '/home/vagrant/Code/Laravel/node_modules/node-sass/vendor'
    at Error (native)
    at Object.fs.readdirSync (fs.js:952:18)
    at Object.getInstalledBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/extensions.js:124:13)
    at foundBinariesList (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/binding.js:15:30)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/sass-loader/lib/loader.js:3:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)

 @ ./resources/assets/sass/app.scss 4:14-266
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

 error  in ./resources/assets/sass/app.scss

Module build failed: ModuleBuildError: Module build failed: Error: ENOENT: no such file or directory, scandir '/home/vagrant/Code/Laravel/node_modules/node-sass/vendor'
    at Error (native)
    at Object.fs.readdirSync (fs.js:952:18)
    at Object.getInstalledBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/extensions.js:124:13)
    at foundBinariesList (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/binding.js:15:30)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/sass-loader/lib/loader.js:3:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at runLoaders (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModule.js:194:19)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:170:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:27:11)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModule.js:181:3)
    at NormalModule.build (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModule.js:274:15)
    at Compilation.buildModule (/home/vagrant/Code/Laravel/node_modules/webpack/lib/Compilation.js:146:10)
    at moduleFactory.create (/home/vagrant/Code/Laravel/node_modules/webpack/lib/Compilation.js:433:9)
    at factory (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:241:5)
    at applyPluginsAsyncWaterfall (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:94:13)
    at /home/vagrant/Code/Laravel/node_modules/tapable/lib/Tapable.js:268:11
    at NormalModuleFactory.params.normalModuleFactory.plugin (/home/vagrant/Code/Laravel/node_modules/webpack/lib/CompatibilityPlugin.js:52:5)
    at NormalModuleFactory.applyPluginsAsyncWaterfall (/home/vagrant/Code/Laravel/node_modules/tapable/lib/Tapable.js:272:13)
    at resolver (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:69:10)
    at process.nextTick (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:194:7)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
                                                                                                                Asset     Size  Chunks                    Chunk Names
/js/app.js  1.21 MB       0  [emitted]  [big]  /js/app

npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "development"
npm ERR! node v6.11.2
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 2
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 2
npm ERR!
npm ERR! Failed at the @ development script '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! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     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! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/.npm/_logs/2017-08-07T08_05_41_440Z-debug.log

npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.11.2
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ dev script 'npm run development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/.npm/_logs/2017-08-07T08_05_41_500Z-debug.log

And even after adjusting package.json to the new commands on this repo it now claims that Webpack is not installed!

vagrant@homestead:~/Code/Laravel$ npm run dev

> @ dev /home/vagrant/Code/Laravel
> NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

sh: 1: webpack: not found

npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.11.2
npm ERR! npm  v4.2.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ dev: `NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @ dev script 'NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/.npm/_logs/2017-08-07T08_26_53_134Z-debug.log

@patlecat

  1. If you install Laravel, then you SHOULD see cross-env in package.json. If you install just Laravel Mix for any other projects, perhaps not Laravel, then you SHOULD NOT see cross-env in package.json.
  2. If you look at the error properly, your node-sass is not installed correctly. For that, it's better to check with https://github.com/sass/node-sass repo.
  3. If you have made changes to your package.json in your Laravel project, then it's better than you delete node_modules folder and package-lock.json file and doing a npm install again to make sure that the bin links are properly installed to use the short path to webpack.

@ruchern Thanks for the details, I didn't know about cross-env being exclusive to Laravel, but then at home the package.json worked well just without calling cross-env. Which is still weird. But from another issue here Jeffrey explained why and where cross-env is needed (not in the docs though), this explains why package.json worked without it under Homestead-Ubuntu.

At home I rebuilt node-sass (I believe) with npm rebuild and it did so via GCC. Took a long time but then all worked fine (without cross-env).

At work I did a fresh reinstall of Laravel and the local node modules as you remember. And I really had the kind of problems I mentioned now several times using fresh installations for about 8 months now. Sometimes removing the call of cross-env helped sometimes something else fixed a problem and it gets just weirder and weirder for me, one time you tell me to remove the cross-env call then you and Jeffrey tell me that it's good as it is, but still won't work and reconfiguring without it gets me one step further!

If you remember I made no changes anywhere in any files before you instructed me to do so. Like removing node_modules and reinstalling everything again. But if I'm installing an incompatible version of nonde-sass then you should prevent that from happening in the package.json or in the Mix file.

Especially my last failed trial is very easily reproducible for you guys, it's just a matter of wanting to try it out yourself. And I am aware that some of my various weird errors I'm getting come from other node-modules or webpack that got changes over the last months that did something you did not expect or did not follow up on.

@patlecat What environment configuration is your work using?

npm, node, OS, OS version?

@ruchern Please look at the top of this issue for a my setup and what I did exactly. I use the exactly setup and versions at home and at work.

@ruchern Btw I looked at the webpack.config.js (in ...Laravelnode_modules\laravel-mixsetup), why is it referring to a src/ folder that does not exist? Or what folder should that be? Because it's still complaining that Webpack is not installed, but it is!

require('../src/index');
require(Mix.paths.mix());
Mix.dispatch('init', Mix);
let WebpackConfig = require('../src/builder/WebpackConfig');
module.exports = new WebpackConfig().build();

You don't need to look at Mix's webpack.config.js file. It's a relative path to the src folder, which does exist.

@JeffreyWay Okay so I know where not to look to. But that won't solve my problems. I'm giving you a lot of detail infos with a systematic approach to help you since this is an OS project. So help me to help you! :)

@patlecat Help Jeffrey Way?

I do not see anyone had this much problems setting up Laravel Mix like you. Just try updating all your packages, npm and nodejs versions to the latest. Wipe your node_modules folder and try again.

@ruchern + @JeffreyWay I don't know where you get user feedback from. But after posting in a Laravel group on fb, I already got people telling to have similar problems with Mix or other problems. And they use Homestead and Windows predominantly, few also Linux. No one Mac so far. I had hoped to give you good input and to work with you making Mix more stable, that's why I spent so much time here. But it's really up to you guys, what do you want to make of it?

As soon as I start my next project I won't have time to play around anymore with a buggy product and environment.

@ruchern Okay I reinstalled both Homestead, it's box and Laravel anew again! Now I get a different error again. It seems to stop around Sass compilation again but now with an error that it can't find the vendor/ folder, but I was unable to find where anyone looks for that folder.

vagrant@homestead:~/Code/Laravel$ npm run dev

> @ dev /home/vagrant/Code/Laravel
> npm run development


> @ development /home/vagrant/Code/Laravel
> NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting

 ERROR  Failed to compile with 2 errors                                                                      12:22:34 PM

 error  in ./resources/assets/sass/app.scss

Module build failed: Error: ENOENT: no such file or directory, scandir '/home/vagrant/Code/Laravel/node_modules/node-sass/vendor'
    at Error (native)
    at Object.fs.readdirSync (fs.js:952:18)
    at Object.getInstalledBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/extensions.js:124:13)
    at foundBinariesList (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/binding.js:15:30)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/sass-loader/lib/loader.js:3:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)

 @ ./resources/assets/sass/app.scss 4:14-266
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

 error  in ./resources/assets/sass/app.scss

Module build failed: ModuleBuildError: Module build failed: Error: ENOENT: no such file or directory, scandir '/home/vagrant/Code/Laravel/node_modules/node-sass/vendor'
    at Error (native)
    at Object.fs.readdirSync (fs.js:952:18)
    at Object.getInstalledBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/extensions.js:124:13)
    at foundBinariesList (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/binding.js:15:30)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/vagrant/Code/Laravel/node_modules/sass-loader/lib/loader.js:3:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at runLoaders (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModule.js:194:19)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:170:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:27:11)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/home/vagrant/Code/Laravel/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModule.js:181:3)
    at NormalModule.build (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModule.js:274:15)
    at Compilation.buildModule (/home/vagrant/Code/Laravel/node_modules/webpack/lib/Compilation.js:146:10)
    at moduleFactory.create (/home/vagrant/Code/Laravel/node_modules/webpack/lib/Compilation.js:433:9)
    at factory (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:241:5)
    at applyPluginsAsyncWaterfall (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:94:13)
    at /home/vagrant/Code/Laravel/node_modules/tapable/lib/Tapable.js:268:11
    at NormalModuleFactory.params.normalModuleFactory.plugin (/home/vagrant/Code/Laravel/node_modules/webpack/lib/CompatibilityPlugin.js:52:5)
    at NormalModuleFactory.applyPluginsAsyncWaterfall (/home/vagrant/Code/Laravel/node_modules/tapable/lib/Tapable.js:272:13)
    at resolver (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:69:10)
    at process.nextTick (/home/vagrant/Code/Laravel/node_modules/webpack/lib/NormalModuleFactory.js:194:7)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
                                                                                                                Asset     Size  Chunks                    Chunk Names
/js/app.js  1.21 MB       0  [emitted]  [big]  /js/app

npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "development"
npm ERR! node v6.11.2
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ development: `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 2
npm ERR!
npm ERR! Failed at the @ development script 'NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/.npm/_logs/2017-08-10T12_22_34_389Z-debug.log

npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.11.2
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ dev script 'npm run development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/.npm/_logs/2017-08-10T12_22_34_460Z-debug.log

@patlecat Looks like you're still having installation issues.

no such file or directory, scandir '/home/vagrant/Code/Laravel/node_modules/node-sass/vendor'

It needs Sass to work, but it doesn't appear to be installed. None of this is related to Mix specifically. I honestly have no idea why your installation isn't working properly.

@patlecat Your issue is node-sass related. Look for your issue here: http://github.com/sass/node-sass

It appears that you are unable to download node-sass properly.

I suggest you completely reinstall npm and try again.

@ruchern Thanks for you ongoing support. I reinstalled everything except Windows now several times and give up on Homestead. Whatever it is that Mix can't get figured out under Homestead is not easily fixed if the different teams do not work together (even though you're both Laravel projects!).

I switched over to Laragon, runs fine for development under Windows. Won't solve my testing needs, but for that I can run a vagrant bento-ubuntu box.

Thanks a lot you both for the efforts.

@patlecat Use Laravel Valet. It's an unofficial port for Windows.

@ruchern Apparently my choices are never yours ;) Why to use the Valet port instead of Laragon?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wendt88 picture wendt88  ·  3Comments

rderimay picture rderimay  ·  3Comments

mementoneli picture mementoneli  ·  3Comments

dtheb picture dtheb  ·  3Comments

jpriceonline picture jpriceonline  ·  3Comments