1

I'm experiencing the same error over and over again when I run npm run prod in my VPS. There is no issue with my local dev machine:

This is the error message, my app is a Laravel app with Vue, I use laravel-mix to compile my assets, my production dev is a DigitalOcean VPS with Ubuntu and LEMP stack:


$ npm run prod

> @ prod /var/www/dtcburger.es
> npm run production


> @ production /var/www/dtcburger.es
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

internal/child_process.js:313
    throw errnoException(err, 'spawn');
    ^

Error: spawn ENOMEM
    at ChildProcess.spawn (internal/child_process.js:313:11)
    at exports.spawn (child_process.js:508:9)
    at Object.exports.fork (child_process.js:109:10)
    at fork (/var/www/dtcburger.es/node_modules/worker-farm/lib/fork.js:17:36)
    at Farm.startChild (/var/www/dtcburger.es/node_modules/worker-farm/lib/farm.js:106:16)
    at Farm.processQueue (/var/www/dtcburger.es/node_modules/worker-farm/lib/farm.js:279:10)
    at Farm.<anonymous> (/var/www/dtcburger.es/node_modules/worker-farm/lib/farm.js:97:21)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gabotron/.npm/_logs/2019-05-26T16_59_29_167Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ prod: `npm run production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gabotron/.npm/_logs/2019-05-26T16_59_29_200Z-debug.log
David Buck
  • 3,752
  • 35
  • 31
  • 35
gabogabans
  • 3,035
  • 5
  • 33
  • 81
  • https://stackoverflow.com/questions/26193654/node-js-catch-enomem-error-thrown-after-spawn – Rwd May 26 '19 at 22:45

2 Answers2

5

If your Digital Ocean droplet only has 1GB of memory, you might run into memory issues whilst running your npm production script. To solve this you could try upsizing your droplet to a larger droplet or running your production script with the --silent flag:

npm run production --silent
C.Christensen
  • 386
  • 4
  • 8
0

You might have forgotten to do npm install first. Also maybe composer install. It's hard to say as the error message is rather unspecific. It might be helpful to see the contents of:

/home/gabotron/.npm/_logs/2019-05-26T16_59_29_167Z-debug.log

kaan_a
  • 3,503
  • 1
  • 28
  • 52