Search code examples
node.jslaravelnpmlaravel-mixlaravel-forge

Laravel Forge - "killed" - npm verb exit 137 - dying on Laravel Mix


I recently updated the versions of Node and NPM on my server on Forge from Node v14.19.0 to v18.17.1 and NPM v.6.14.16 to v9.6.7. I have also updated my dependencies. Not sure if this is relevant, but I needed to change Forge's password on the server.

When deploying, npm install runs fine but when I run npm run dev, I always get the response "Killed" from Forge. Specifically "npm verb exit 137", which indicates that I have run out of memory.

Here is the output:

> dev
> mix

QUEUE_CONNECTION set to "redis", make sure to start a queue worker.

● Mix █████████████████████████ emitting (98%)
 after emit

Outbound Data: File generated!
Ziggy Routes: Files generated!
Killed

I have tried to fix this by adding the max-old-space-size to my script:

"dev": "NODE_OPTIONS=\"--max-old-space-size=8000\" mix "

However, this hasn't helped and the I keep getting the same error.

I have also tried to run npm run prod and am getting the same error.

I have also tried getting into the server via SSH and running npm run dev and npm run prod. Unfortunately, this doesn't give me any further information.

I have also tried running npm cache clean --force and then running npm run dev, but am having the same issue.

Any idea what could be happening here and how to fix it?

Thanks!


Solution

  • As was pointed out in the comments, the reason for the error was that the server was too small (despite working perfectly fine before). What fixed it was upgrading from a t3.small (2GB memory) to a t3.medium (4GB memory).