Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nanosolutions's avatar

Laravel-Mix (WebPack) does not work on Linux when deploying (work on mac)

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

0 likes
14 replies
nanosolutions's avatar

npm install yes, even if there was module missing we woudl get error right?

zachleigh's avatar

I believe so, but not sure how webpack does it. Are you doing this on a server?

nanosolutions's avatar

Of course every depley we run npm install and then npm run production.

It does produces something but it's almost 0 size compere to what is ment o be.

zachleigh's avatar

Compile your resources locally and push them up to your server when you deploy. You really shouldn't be running your npm scripts on a production server.

nanosolutions's avatar

This has been wokring fine for us for years, but L5.4 has Webpack and does not work so well (yet) I am not gonan commit compiled assets into git , seem waste of space.. Compling on server seem OK for us. It just need to work.

zachleigh's avatar

Well, having all your node_modules on your server is probably taking a lot more space than compiled assets. And having to install node_modules and run npm scripts every time you deploy must be a headache. But, its your project.

Does /css/login.css exist?

ejdelmonico's avatar

As @zachleigh states, you are misunderstanding the deployment process and the basics of Webpack. With Webpack, everything is a dev dependency unless you are going to use it separately in production. Everything is bundled up and ready to use so those processed files are committed to the repo and deployed for production. You should not be installing any dev dependencies or running npm scripts on the production server.

1 like
nanosolutions's avatar

@ejdelmonico so please tell me how to depoly from git, via application like envoyer.io or deployer and have the files packed for production?

zachleigh's avatar

Simply build your resources locally and include them in your git repo. There is nothing specific you have to do.

nanosolutions's avatar

@zachleigh but you will commit compiled sources file, which will be different everytime, can not version it very well with mix naming and your repo will grow bigger for no reason.

Anyway. My problem is that laravel-mix does not work very well on Linux , and I am trying to find out why.

zachleigh's avatar

It works fine on Linux. Im guessing it has something to do with your production environment.

Yes, the compiled files are different when you change something. And thats fine. They are versioned along with the rest of the files in your app. As far as repo size... Ive never had a problem.

ejdelmonico's avatar

@nanosolutions It would be advisable that you do some reading on modern workflows and how a repo is used in different scenarios. You, my friend, definitely do not understand the process of versioning and effective use of deploying from a repo.

2 likes

Please or to participate in this conversation.