3

Node-red version: 0.19.5
PM2 version: 3.2.3
OS: Windows Embedded Standard 7 (Running on ICO300, with 8gb of RAM)

Steps to reproduce

  1. Install node-red and pm2 on Windows ES 7
  2. Run node red through pm2: pm2 start node-red
  3. Check node-red logs: pm2 logs node-red

Result
I got the following error:

0|node-red  | SyntaxError: Invalid or unexpected token
0|node-red  |     at new Script (vm.js:79:7)
0|node-red  |     at createScript (vm.js:251:10)
0|node-red  |     at Object.runInThisContext (vm.js:303:10)
0|node-red  |     at Module._compile (internal/modules/cjs/loader.js:656:28)
0|node-red  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
0|node-red  |     at Module.load (internal/modules/cjs/loader.js:598:32)
0|node-red  |     at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
0|node-red  |     at Function.Module._load (internal/modules/cjs/loader.js:529:3)
0|node-red  |     at Object.<anonymous> (c:\Users\Administrator\AppData\Roaming\npm\node_modules\pm2\lib\ProcessContainerFork.js:27:21)
0|node-red  |     at Module._compile (internal/modules/cjs/loader.js:688:30)
0|node-red  | C:\USERS\ADMINISTRATOR\APPDATA\ROAMING\NPM\NODE-RED.CMD:1
0|node-red  | (function (exports, require, module, __filename, __dirname) { @IFEXIST "%~dp0\node.exe" (

and node-red does not run.

Running node-red directly from CMD can be done normally (except that after 1 hour it usually crashes (cause discussed here, still unsolved), that's why as a workaround I want to use PM2 to auto-restart it.)

Leonard AB
  • 1,479
  • 1
  • 19
  • 30
  • All of that stacktrace is in the PM2 code, you should probably update the question with how you configured PM2 – hardillb Dec 18 '18 at 08:09
  • Also having PM2 auto restart is a bad solution, it would be better to work why Node-RED is crashing (separate question) – hardillb Dec 18 '18 at 08:10
  • @hardillb yup, I finally found out the cause for that crash, and it seems it is a bug on a node I use (azure IoT hub). It is discussed here https://github.com/lcarli/NodeRedIoTHub/issues/23#issuecomment-448087319 but there is still no solution so far. – Leonard AB Dec 18 '18 at 23:25

1 Answers1

6

On Windows, the node-red.cmd is not a valid, you have to run directly the Node.js command instead:

pm2 start C:\Users\<USER-NAME>\AppData\Roaming\npm\node_modules\node-red\red.js
Unitech
  • 5,781
  • 5
  • 40
  • 47