Pra*_*ass 5 windows node.js pm2
我正在尝试npm使用ecosystem.jsonas通过 pm2运行自定义脚本,
{
"apps": [{
"name": "Service",
"script": "npm",
"args": "run command"
}]
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,我无法做到。谁能帮我解决这个问题?我得到如下所示,
C:\PROGRAM FILES\NODEJS\NPM.CMD:1
0|Service | (function (exports, require, module, __filename, __dirname) { ::
Created by npm, please don't edit manually.
0|Service | ^
0|Service | SyntaxError: Unexpected token :
0|Service | at createScript (vm.js:56:10)
0|Service | at Object.runInThisContext (vm.js:97:10)
0|Service | at Module._compile (module.js:542:28)
0|Service | at Object.Module._extensions..js (module.js:579:10)
0|Service | at Module.load (module.js:487:32)
0|Service | at tryModuleLoad (module.js:446:12)
0|Service | at Function.Module._load (module.js:438:3)
0|Service | at Object.<anonymous>
(C:\Users\AD001\AppData\Roaming\npm\node_modules\pm2\
lib\ProcessContainerFork.js:53:21)
0|Service | at Module._compile (module.js:570:32)
0|Service | at Object.Module._extensions..js (module.js:579:10)
Run Code Online (Sandbox Code Playgroud)
小智 8
这是 pm2 中报告的问题。你可以通过做来解决
//startscript.js
var exec = require('child_process').exec;
exec('npm start', {windowsHide: true});
Run Code Online (Sandbox Code Playgroud)
然后pm2启动startscript.js