Hi there, I'm using Laravel 5.4.15 and my node_modules folder is outside project root. I have trouble migrating from elixir to mix.
The physical path is:
/var/www/vhosts/example.com/persistent/node_modules
Project root is:
/var/www/vhosts/example.com/releases/release_uuid_changes_all_the_time
Now in project root, I have setup a symlink to node_modules like this:
/var/www/vhosts/example.com/releases/release_uuid/node_modules => /var/www/vhosts/example.com/persistent/node_modules
This is done so I don't have to keep the huge node_modules folder in VCS, only the configuration. I'm pretty sure this is a common setup.
When after npm install I first ran npm run dev I encountered:
Error: Cannot find module '/var/www/vhosts/example.com/releases/2017-03-04_23-50-23_d1f0128/node_modules/cross-env/bin/cross-env.js'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:422:7)
at startup (bootstrap_node.js:143:9)
at bootstrap_node.js:537:3
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.6.0
npm ERR! npm v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `node node_modules/cross-env/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
etc, so I had to change the "scripts" section of my package.json to this:
"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 node_modules/webpack-dev-server/bin/webpack-dev-server.js --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"
},
Now cross-env is working fine, but when running npm run dev I hit the next error:
Error: Cannot find module '/var/www/vhosts/example.com/persistent/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 (/var/www/vhosts/example.com/persistent/node_modules/laravel-mix/src/Mix.js:42:9)
at Object.<anonymous> (/var/www/vhosts/example.com/persistent/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 (/var/www/vhosts/example.com/persistent/node_modules/webpack/bin/convert-argv.js:96:18)
at /var/www/vhosts/example.com/persistent/node_modules/webpack/bin/convert-argv.js:109:17
at Array.forEach (native)
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.6.0
npm ERR! npm v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `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
So basically it's trying to look for webpack.mix.js inside the physical location of node_modules instead of the project root, how do I tell it the other way round?
I'm kinda new to webpack and mix so need help here please!