How stop Node Red under Windows when started from pm2

Hi, I've a module which doesn't work in best way, and I need to stop manually NR to reset its queuem how can I do it by command line? there is no node-red-stop batch like on Pi.
I've started NR under pm2 to ensure it works even in case of faults, should I use pm2 commands to stop it?

You need to read up on PM2 commands.

You can restart node-red with something like pm2 restart Node-RED --update-env; pm2 logs (that will also show the logs in the terminal. Your pm2 session name might be different from Node-RED as I've called mine.

You can also do pm2 kill which kills pm2 completely.

I have all these things set up as npm scripts in my package.json file so I only need to do npm restart which runs pm2 restart Node-RED --update-env && pm2 logs.

I have a pm2 config file so npm start runs pm2 start ecosystem.config.js && pm2 logs.

thanks for answer, npm restart doesn't work for me (done on node red flder where is package.json file, maybe I've to do it on pm2 folder?

C:\Users\Admin\.node-red>npm restart

> node-red-project@0.0.1 restart
> npm stop --if-present && npm start

npm error Missing script: "start"
npm error
npm error Did you mean one of these?
npm error   npm star # Mark your favorite packages
npm error   npm stars # View packages marked as favorites
npm error
npm error To see a list of scripts, run:
npm error   npm run
npm error A complete log of this run can be found in: C:\Users\Admin\AppData\Local\npm-cache\_logs\2024-11-03T22_14_35_105Z-debug-0.log

pm2 kill works, then I have to start it again with pm2 start, but NR will start only with pm2 start C:\Users<USER-NAME>\AppData\Roaming\npm\node_modules\node-red\red.js

pm2 restart doesn't exist, as well pm2 restart Node-RED --update-env && pm2 logs returns an error, I've probably to restart red.js

my best solution is to restart pm2, do you know how to? Thanks

You need to configure your package.json correctly.

Here is what I have:

D:\src\nr>npm run
Lifecycle scripts included in node-red-master@2.0.3:
  start
    pm2 start ecosystem.config.js && pm2 logs
  restart
    pm2 restart Node-RED --update-env && pm2 logs

An extract of my ecosystem config file:

Note that I'm using my alternate installer so Node-RED is installed locally not globally and the userDir home folder is in the data sub-folder under the node-red folder.

thanks for help, honestly.. I don't feel to pay attention much about this, all is working, I have lot of work and can't spend time learning something I don't know, read documentations and so on.
I know how to stop and how to start pm2 back, but I would like to know if there is a quick way to restart it. If not, I'll make a batch file :slight_smile:

Yes, as already mentioned. Since I keep the terminal window open where I start Node-RED, restart is as simple as ctrl-c to exit the log then npm restart. Even simpler if I've changed a watched file since PM2 does it all for me.

I haven't any window with NR, it is executed automatically in background from pm2 during boot.
Npm restart doesn't works for me, as I posted above