Found similar questions but none helped in my case:
run pm2 logs error SyntaxError: Unexpected token
The versions for my node, npm and pm2 are:
node: v6.14.3
npm: v3.10.10
pm2: v2.10.2
I'm trying to deploy an angular app with pm2
in my corporate linux environment that has no internet access. I have installed pm2
via the command below from my corporate artifact repository by setting npm registry:
$ npm install -g pm2
Installation was successful and I could see a folder in my node modules folder at /home/MY_ID/node_modules/pm2
. Somehow the path variable was not set so I was not able to run any pm2
command. So I ran the following command in my terminal to set pm2
path variable:
$ export PATH=$PATH:/home/MY_ID/node_modules/pm2/bin
After which I tried running command pm2 -v
to check for pm2
, I got the error below:
SyntaxError: Unexpected token ...
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/MY_ID/node_modules/pm2/constants.js:10:14)
May I know what did I do wrong here? Could it be that the path was set wrongly or the pm2
was not installed properly?
From pm2's github page:
All Node.js versions are supported starting Node.js 8.X.
You need to install a more recent version of nodejs (at least v 10, v6 is very old).
Regarding that error, the problem might be that pm2 is using the spread operator with an object, which is not supported until nodejs 8.3 (or v 8.0 running with --harmony
flag).
Example
let clone = {...object};