Cannot find module webpack.mix
See original GitHub issue- Node Version (
node -v): v7.4.0 - NPM Version (
npm -v): v4.0.5 - OS: Ubuntu 16
Description:
On production server get an error when running npm run dev or production. On local env works fine. Server is a DO server with forge and Envoyer for deploymemts. I think there is something related to the virtual links.
Error I get is:
node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
module.js:472 throw err; ^
Error: Cannot find module ‘/home/forge/XXXX/storage/app/webpack.mix’ at Function.Module._resolveFilename (module.js:470:15) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Mix.initialize (/home/forge/pitz.es/storage/app/node_modules/laravel-mix/src/Mix.js:45:9) at Object.<anonymous> (/home/forge/pitz.es/storage/app/node_modules/laravel-mix/setup/webpack.config.js:18:5) at Module._compile (module.js:571:32) at Object.Module._extensions…js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at requireConfig (/home/forge/pitz.es/storage/app/node_modules/webpack/bin/convert-argv.js:96:18) at /home/forge/pitz.es/storage/app/node_modules/webpack/bin/convert-argv.js:109:17 at Array.forEach (native)
npm ERR! Linux 4.4.0-57-generic
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “run” “dev”
npm ERR! node v7.4.0
npm ERR! npm v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! pitz@1.0.0 dev: node node_modules/cross-env/dist/bin/cross-env.js 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 pitz@1.0.0 dev script ‘node node_modules/cross-env/dist/bin/cross-env.js 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 pitz package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node node_modules/cross-env/dist/bin/cross-env.js 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 pitz
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls pitz
npm ERR! There is likely additional logging output above.
Steps To Reproduce:
npm run dev
Issue Analytics
- State:
- Created 7 years ago
- Comments:22 (1 by maintainers)
Top Related StackOverflow Question
Mix needs to have a webpack.mix.js file in the project root, so if it can’t find one, it makes sense that it will fail. I don’t think there’s anything we can do to this repo to fix your issue.
A lot of people prefer to do their production builds locally.
Hi @aspitzer! My workaround for using a symlinked
node_modulesfolder was to copy/paste thewebpack.config.jsfrom this repo to my project root (sibling towebpack.mix.jsandpackage.json).Then, I added a line to the copied file before
Mix.initialize()which corrects the root path to the current directory (not the location of the symlinked modules):Finally, I updated the
productionscript insidepackage.jsonto"node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=webpack.config.js"This is necessary because the constructor value for
Mix.Paths.root()usespath.resolve()to find the current context. I don’t know NodeJS well enough to suggest an alternative approach, and the workaround above works fine for me 😃cc https://github.com/JeffreyWay/laravel-mix/issues/386