Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.6k stars 2.62k forks source link

pm2 does not work with bat file on Windows #5235

Open BBE78 opened 2 years ago

BBE78 commented 2 years ago

What's going wrong?

starting pm2 with a .bat file raised an error

What do you expect?

I expect pm2 to work with Windows scripts (.bat, .cmd, .ps files) and documentation updated accordingly, or a more clear documentation about restrictions (if any) on Windows. All samples, or code snippets in the documentation is about .sh scripts (so with Linux).

Environment

How could we reproduce this issue?

test-pm2.bat:

@timeout /t 30

then try: pm2 start test-pm2.bat

Supporting information

pm2 error log file:

@timeout /t 30
^

SyntaxError: Invalid or unexpected token
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Object.<anonymous> (C:\Tools\node\node-v14.17.1-win-x64\node_modules\pm2\lib\ProcessContainerFork.js:33:23)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
linonetwo commented 1 year ago

Try change interpreter field.

Or do like mine:

script: 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
      args: 'run start',
      cwd: 'D:/repo/qq-bot',

https://github.com/tiddly-gittly/qq-bot

thomasmost commented 8 months ago

@linonetwo Change interpreter to what??