Yugi's avatar
Level 23

How to change default webpack.mix path?

I am really frustrated about this issue, I am just trying to run npm run dev but laravel-mix is trying to read the webpack.mix file from '/home/vagrant/projectname/webpack.mix', the problem is that the actual path is '/vagrant/projectname/webpack.mix', I just want to change that path, that's the only thing I want to do, and from a beginner's look, it is not that easy.

Update: After a lot of tracing, I arrived at the function that is responsible for it, it is in node_modules/laravel-mix/src/Paths.js, in there look for the mix() function and bingo, but once I changed the output this function returns, yes webpack started looking in the right directory, but I ran into another error, here's it:

77% module and chunk tree optimization unnamed compat plugin/home/vagrant/pirlanta/node_modules/webpack/lib/Chunk.js:824
                throw new Error(
                ^

Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
    at Chunk.get (/home/vagrant/pirlanta/node_modules/webpack/lib/Chunk.js:824:9)
    at /home/vagrant/pirlanta/node_modules/laravel-mix/node_modules/extract-text-webpack-plugin/dist/index.js:176:47
    at Array.forEach (<anonymous>)
    at /home/vagrant/pirlanta/node_modules/laravel-mix/node_modules/extract-text-webpack-plugin/dist/index.js:171:18
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/vagrant/pirlanta/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:12:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/home/vagrant/pirlanta/node_modules/webpack/node_modules/tapable/lib/Hook.js:35:21)
    at Compilation.seal (/home/vagrant/pirlanta/node_modules/webpack/lib/Compilation.js:1213:27)
    at hooks.make.callAsync.err (/home/vagrant/pirlanta/node_modules/webpack/lib/Compiler.js:547:17)
    at _err0 (eval at create (/home/vagrant/pirlanta/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:11:1)
    at _addModuleChain (/home/vagrant/pirlanta/node_modules/webpack/lib/Compilation.js:1064:12)
    at processModuleDependencies.err (/home/vagrant/pirlanta/node_modules/webpack/lib/Compilation.js:980:9)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Notice in the error, every time it renders the path it starts with '/home/',

I think what's causing this is the symlink I have between the node_modules in the root of the project, and node_modules folder in the '/home/' directory of the VM, not sure what could be the fix of that.

Just to make things a bit clearer, I have these two directories in the VM:

'/home/vagrant/pirlanta/' // And inside here there's a folder named 'node_modules'

'/vagrant/pirlanta/' // Which holds the actual Laravel application.

Both directories are linked together like this:

ln -s ~/pirlanta/node_modules node_modules

FWIW, here's my environment, I am running a centOS VM on a Windows host with:

PHP 7.1.6 Laravel 5.6.33 npm 5.3.0

0 likes
2 replies
automica's avatar

Are you running npm on your host machine or inside your vm?

Please or to participate in this conversation.