pm2 start "npm start" doesn't work
Hi:
pm2 start "npm start" doesn't work. I get this error:
[PM2][ERROR] Script not found: D:\Coding\project\npm start
I am using Windows 10. pm2 version 5.2.2
Same error with pm2 start "npm run start"
How execute npm scripts?
Thanks!
try pm2 start npm -- start
try
pm2 start npm -- start
Hi. Same error with pm2 start npm -- start
Hi @pols63 can you show us the project or the package.json here?
Yes, sure:
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node ."
},
"author": "",
"license": "ISC"
}
I've noted:
- In the powershell inside VSCode, this commands
pm2 start "npm start"andpm2 start npm -- startshow this error:
connect EPERM //./pipe/rpc.sock
[PM2] Spawning PM2 daemon with pm2_home=C:\Users\jean.sanchez\.pm2
node:events:491
throw er; // Unhandled 'error' event
^
Error: connect EPERM //./pipe/rpc.sock
at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1300:16)
Emitted 'error' event on ReqSocket instance at:
at Socket.<anonymous> (C:\Users\jean.sanchez\AppData\Roaming\npm\node_modules\pm2\node_modules\pm2-axon\lib\sockets\sock.js:201:49)
at Socket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4048,
code: 'EPERM',
syscall: 'connect',
address: '//./pipe/rpc.sock'
}
Node.js v18.10.0
- In the Powershell:
pm2 start "npm start"
[PM2][ERROR] Script not found: D:\Coding\test\npm start
pm2 start npm -- start
[PM2] Applying action restartProcessId on app [npm](ids: [ 0 ])
[PM2] [npm](0) ✓
[PM2] Process successfully started
[PM2][ERROR] Script not found: D:\Coding\test\start
Greetings
I'm getting the same issue.
the same to me, and anybody knows why?
I had to remember to run it as administrator.
Same here. It works in WSL, but not in Powershell even running as administrator
I believe this is related to #5763 and how PS handles parameters.
The end-of-parameters token (--) indicates that all arguments following it are to be passed in their actual form as though double quotes were placed around them.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parsing?view=powershell-7.3#the-end-of-parameters-token
So far, I have not found a way to deal with it. Neither pm2 start npm -- start or pm2 start "npm start" or pm2 start npm "start" or pm2 start npm -- "start" do the trick.
The parameter is always seen as an additional app to be started.
[PM2] Applying action restartProcessId on app [npm](ids: [ 0 ])
[PM2] [npm](0) ✓
[PM2] Process successfully started
[PM2][ERROR] Script not found: C:\test\start
This may go down to:
This behavior only applies to PowerShell commands. If you use the -- token when calling an external command, the -- string is passed as an argument to that command.
How about pm2 start npm -- -- start? The first -- is for powershell, and the second -- is for pm2. It worked for me on windows 11 powershell7.
Does anyone have any further info on this? I've done my one or two hours of internet searching with no luck.
I attempted @ilovenewts's suggestion, however that didn't seem to work either, so I'm a bit stumped on what else to try.
PM2 v5.4.0 Node.js v18.17.0 OS: Windows Server 2022 Standard v10.0.20348.587
Maybe pm2 start npm -- run start
It helped on a linux server