Solvedpm2 pm2 start npm -- start error
✔️Accepted Answer
This is still happening on my Windows 10 machine. Whatever globally installed program from npm I try to start from pm2, it gives me this error.
Seems like pm2 assumes the program passed (npm, verdaccio, or whatever) to be a js file to be run with node, when they actually are .cmd files.
Reason I think so : you get the exact same errors if you locate the <app>.cmd
file and try to run
node <path_to_app>/<app>.cmd
. Of course node doesn't like to have to run a .cmd file.
I wonder however why pm2 makes that assumption. Because if you try pm2 start node
for example, that works fine. It seems to only make the assumption on programs installed from npm (but I haven't tested a ton either).
However that all means there is a relatively easy workaround if you need it for now. As pm2 assumes a js file, just pass to pm2 the .js file that the .cmd is trying to run. Locate the .js that the .cmd is trying to run, and give the absolute path to pm2. For instance:
pm2 start "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js"
or
pm2 start C:\Users\Nicolas\AppData\Roaming\npm\node_modules\...\<script>.js
That also works if you put it in the ecosystem file, as the script
entry for the app.
Other Answers:
I am also unable to find the solution.Getting below error :
SyntaxError: Unexpected token ':'
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Object. (C:\Users\suresh-negi\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:32:23)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
+1
@nguiard Thanks for your workaround, works as expected. Only thing is I get a cmd window open whenever I run the command. Any idea how to prevent this?
Your issue may already be reported!
Please search on the issue tracker before creating one.
What's going wrong?
After I run
pm2 start npm -- start
,then get errored.error info is
I found someone get the same error in stackoverflow.
Maybe it only get errored in win10, It works in my macbook.
How could we reproduce this issue?
1.clone https://github.com/marekchen/pm-web3
2.npm install
3.npm run build
4.pm2 start npm -- start
Supporting information
===============================================================================
--- PM2 REPORT (Fri May 11 2018 11:01:16 GMT+0800 (中国标准时间)) -------------------
--- Daemon -------------------------------------------------
pm2d version : 2.10.3
node version : 8.11.1
node path : undefined
argv : C:\Program Files\nodejs\node.exe,C:\Users\marek\AppData\Roaming\npm\node_modules\pm2\lib\Daemon.js
argv0 : node
user : undefined
uid : N/A
gid : N/A
uptime : 58min
--- CLI ----------------------------------------------------
local pm2 : 2.10.3
node version : 8.11.1
node path : undefined
argv : C:\Program Files\nodejs\node.exe,C:\Users\marek\AppData\Roaming\npm\node_modules\pm2\bin\pm2,report
argv0 : node
user : chenpei
--- System info --------------------------------------------
arch : x64
platform : win32
type : Windows_NT
cpus : Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
cpus nb : 8
freemem : 8662110208
totalmem : 17035272192
home : C:\Users\marek
--- PM2 list -----------------------------------------------
┌──────────┬────┬──────┬─────┬─────────┬─────────┬────────┬─────┬────────┬─────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼──────┼─────┼─────────┼─────────┼────────┼─────┼────────┼─────────┼──────────┤
│ pm-web │ 0 │ fork │ 0 │ errored │ 15 │ 0 │ 0% │ 0 B │ chenpei │ disabled │
└──────────┴────┴──────┴─────┴─────────┴─────────┴────────┴─────┴────────┴─────────┴──────────┘
--- Daemon logs --------------------------------------------
┌──────────┬────┬──────┬─────┬─────────┬─────────┬────────┬─────┬────────┬─────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼──────┼─────┼─────────┼─────────┼────────┼─────┼────────┼─────────┼──────────┤
│ pm-web │ 0 │ fork │ 0 │ errored │ 15 │ 0 │ 0% │ 0 B │ chenpei │ disabled │
└──────────┴────┴──────┴─────┴─────────┴─────────┴────────┴─────┴────────┴─────────┴──────────┘