在生产中运行npm run prod时出错

时间:2019-05-26 17:13:36

标签: npm

当我在VPS中运行npm run prod时,我一遍又一遍地遇到相同的错误,我的本地开发机没有问题:

这是错误消息,我的应用程序是具有vue的laravel应用程序,我使用laravel-mix来编译我的资产,我的生产开发人员是具有ubuntu和LEMP堆栈的DigitaOcean VPS:


$ 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

2 个答案:

答案 0 :(得分:1)

如果Digital Ocean Droplet仅具有1GB内存,则在运行npm生产脚本时可能会遇到内存问题。为了解决这个问题,您可以尝试将小滴放大为更大的小滴,或者使用--silent标志运行生产脚本:

npm run production --silent

答案 1 :(得分:0)

您可能忘记先做npm install。也可能composer install。很难说,因为错误消息相当具体。查看以下内容可能会有所帮助:

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