Previously, I had node version v0.10.46
installed on my ec2 server. For a recent project, I decided to give pm2 a try and installed pm2 using
npm install pm2 -g
.
But, pm2 start index.js
errored out since the project was using some ES6 syntax with arrow functions and let keyword.
Therefore, I updated the node version using nvm to latest v6.9.1, which is also the same version which we used for developing on local (windows).
However, pm2 start index.js again errored out with the same error:
pm2 show index
hinted that the nodejs version was still not updated. I removed the old nodejs version, installed pm2 again, still of no avail.
I tried with other methods as well, by using:
pm2 start index.js --interpreter=~/.nvm/versions/node/v6.9.1/bin/node
to force pm2 to use the latest installed version of node. Every single try gave me the same errors with the same version of nodejs. Why is Pm2 not taking the latest version of node and sticking with 0.10.46?
If it helps:
which node
~/.nvm/versions/node/v6.9.1/bin/node
which pm2
~/.nvm/versions/node/v6.9.1/bin/pm2
Also, v0.10.46
was NOT installed using nvm.
Edit:
Here are the running pm2 daemons, using ps -ef | grep pm2
:
Note that ec2-user is the logged in user and I also tried the same with root user. I installed nvm running node v6.9.1 and pm2 as root user as well with no success. I get the same error.