Hi
I have very strange problem, I have spinned off brand new 16.04 Ubuntu and same results, when deploy from git (or full checkout) and run npm run dev or npm run prod it just compiled very limited amount of assets:
Asset Size Chunks Chunk Names
mix.js 537 bytes 0 [emitted] mix
mix-manifest.json 26 bytes [emitted]
Then the Laravel App complains that can not find mix Unable to locate Mix file: /css/login.css. Please check your webpack.mix.js output paths and try again.
When I run this on Mac I get this result:
Asset Size Chunks Chunk Names
/js/login.14837ff8fc3cfefcf6bf.js 287 kB 0 [emitted] [big] /js/login
/css/login.22c40956ea8991802501.css 40.7 kB 0 [emitted] /js/login
mix-manifest.json 116 bytes [emitted]
And everything works.
I have same version of node, npm, i have done clean fresh install of npm install, even clean fresh of OS.
Any ideas?
Thanks
Petr
run npm run dev or npm run prod on server.
Works well for me on Ubuntu 16.04 x64.
It worked for me 1 out of 10 and not sure why :( Spent hours on this. very random problem. Results is that we can not deploy ..
How did you install node there ? Through nvm ?
Also what is the RAM size on that server ? I have faced problems on DigitalOcean where RAM size was 500 mb.
Can you also post your webpack.mix.js code.
Installed it via curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
const { 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');
//
//
mix.js('resources/assets/js/login.js', 'public/js')
.sass('resources/assets/sass/login.scss', 'public/css')
.version().sourceMaps()
@cerw You can try to increase the swap file size on your server. I've had similar issues with automated builds (not with Mix, but still) on Digital Ocean with limited RAM, same as @ankurk91, and increasing the swap size helped me solve that.
@panda-madness I increased my DO Droplet to 4GB ,then run
rm /~.npm
rm ./node_modules
npm install
npm run prod
And then I got this as output:

It does not even include the right files anymore.. 馃槙
This issue happens on my server when using a symlinked node_modules directory.
module.exports.context would contain a reference to the parent of the original node_modules directory, making it unable to locate a webpack.mix.js file.
https://github.com/JeffreyWay/laravel-mix/blob/master/setup/webpack.config.js#L33
This solution may work:
https://github.com/JeffreyWay/laravel-mix/issues/533#issuecomment-287960097
@SabatinoMasala That must be it! I have my node_modules symlinked (same as storage) to speed up the deployment, trying #533 hack now and it works! Thank you, I thought was I was going bit crazy :) 馃憤
More about this subject:
Who does compile assets on the server and who locally (if locally, how do you deploy to the server(s))? Some guys telling me to commit compiled assets into VCS, which I found very dull for many reasons.
If you use GIT -> CI -> CD (in a cloud) there is really no other way then compile assets on deploy? Am I wrong?
P
@cerw did you find any help regarding compiling assets locally or on production? I am also using gitlab ci / cd and want to figure out the best way to do it.
Thanks.
@AdnanMoghal Hi there, I am using this trick, instead of symbolink link I just copy the file from cache
cp -a ~/node_modules .
npm install
export APP_VERSION="{{ branch }}-{{ short_sha }}"
npm run dev
rsync -a node_modules ~/
This way is fast and it work.
Most helpful comment
This issue happens on my server when using a symlinked node_modules directory.
module.exports.contextwould contain a reference to the parent of the original node_modules directory, making it unable to locate awebpack.mix.jsfile.https://github.com/JeffreyWay/laravel-mix/blob/master/setup/webpack.config.js#L33
This solution may work:
https://github.com/JeffreyWay/laravel-mix/issues/533#issuecomment-287960097