React.js或Angular.js应用程序如果我运行npm run serve
可以正常工作,但是当我尝试使用pm2运行服务时,它在Windows中抛出错误,而在Ubuntu中则可以正常工作。
我尝试连接以使用pm2进行投放服务:
pm2 start npm --name="UI" -- run serve
引发错误:
C:\PROGRAM FILES\NODEJS\NPM.CMD:1
(function (exports, require, module, __filename, __dirname) { :: Created by npm, please don't edit manually.
^
SyntaxError: Unexpected token :
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Object.<anonymous> (C:\Users\deepak.chaudhary\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:29:21)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
请尝试使用其他服务启动代理,例如Forever,Supervisor等
这是Forever永远启动您的应用程序的命令。
forever start node_modules/.bin/babel-node tools/distServer.js
让我知道是否行得通。
使用pm2 start "npm run serve" --name="UI"
您可以直接通过PM2 / React脚本导出要使用的端口并启动应用程序:
export PORT=4000 && pm2 start node_modules/react-scripts/scripts/start.js --name "application"