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

Chris1904's avatar

Should I run npm run prod locally or on server?

Hi everyone,

I would like to know what the common convention is when it comes to deploying your source.

I have read multiple different opinions on why I should run npm install && npm run prod on my development machine rather than have it added into the forge deploy script.

Others agreed that it works fine to let forge handle npm install and run prod. Is there a common convention here? If so, why would you choose one over another?

Happy Thanksgiving, Chris

0 likes
3 replies
adamwathan's avatar
Level 6

I personally do it on the server these days, using yarn instead of npm. Both have lock files now so it's not as dangerous as it used to be, and doing it on the server is nice because you don't have to remember to commit a production build of your assets before deploying.

I'd say if you are comfortable running composer install on your server (vs. doing it on a build server and rsyncing it over or similar), installing your npm dependencies on the server is fine.

6 likes
devwootbit's avatar

Hi Adam, i have a trouble, and is that when i ran npm run production on the production server, is like some files are overwritten and this cause me a down time with an error like "file xxxxxxx does not exist" this happens while the process ends

do you know what im missing? ;( i use NPM and laravel mix.

regards from Mexico.

Chris1904's avatar

thanks so much Adam. Appreciate your advice and all your work :-)

Please or to participate in this conversation.