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

lara28580's avatar

Cant deploy npm prod with forge

Hi guys, I have a problem deploying prod code with npm. Every time I try to run npm run prod it generates app.js.LICENSE.txt and then conflicts with forge auto deploy. I dont know what to do to get this to work. Tried also npm ci but throws an error all the time. Read that this should help. Maybe someone of you has an tip how to do it?

best

0 likes
7 replies
aurawindsurfing's avatar

Hi @smoketm

I assume you know that but did you commit your nnode_modules to your git and pushed it to your server? If so you should ignore them in your git, remove them and run npm install & npm update

This should give you some warnings if there are packages that require a licence.

In general removing node_modules is always a good start.

Hope it helps!

1 like
lara28580's avatar

Thanks for your answer but node modules are automatically on the .gitignore so they get not pushed to the repo? And therefore not auto deployed by forge? Or is there something I have missed?

lara28580's avatar

Tried it but get the same error: Your local changes to the following files would be overwritten by merge: public/css/app.css public/js/app.js

It only works if I run it in dev mode

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Well the file is most likely still there from earlier. I normally run git reset --hard before I pull on production. Doing that now should allow you to pull the newest build

1 like
fylzero's avatar

@smoketm node_modules is not deployed via git because it is installed when you call npm install or npm ci on your deployment. You should not remove node_modules from .gitignore ever.

1 like
fylzero's avatar

@smoketm Are you running npm ci before npm run prod? You need to run npm ci first in your deploy script. Otherwise, it will fail.

1 like

Please or to participate in this conversation.