简体   繁体   English

在Windows中通过pm2执行npm脚本的问题

[英]Issue with executing npm scripts via pm2 in Windows

I am trying to run npm custom scripts via pm2 using ecosystem.json as, 我试图运行npm通过PM2自定义脚本使用ecosystem.json为,

{
    "apps": [{
        "name": "Service",
        "script": "npm",
        "args": "run command"
    }]
}

Unfortunately I am unable to do it. 不幸的是我做不到。 Can anyone help me to get through this? 谁能帮我解决这个问题? I am getting as shown below, 我得到如下图所示,

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)

this is a reported issue in pm2. 这是在pm2中报告的问题。 you can work around by doing 你可以通过做

//startscript.js
var exec = require('child_process').exec;
exec('npm start', {windowsHide: true});

then pm2 start startscript.js 然后pm2启动startscript.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM