Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PM2 using wrong node.js version

Tags:

node.js

pm2

I had node version v6.11.1 installed but it was giving error in some package, so i installed v10.15.3 with nvm and set it as default.

#If I run my app directly using node, it uses correct node version v10.15.3 and works
node server.js

#If I run using pm2 it uses old node version v6.11.1 and causes error.
pm2 start server.js

I tried passing --interpreter like

pm2 start server.js --interpreter=~/.nvm/versions/node/v10.15.3/bin/node
#but even this uses v6.11.1

I verify the node version by printing process.version inside my app.

like image 651
Andro Avatar asked Apr 16 '19 16:04

Andro


People also ask

How do I change node js from one version to another?

Switching among Node. 7; we can simply run either nvm use 12.22. 7 or nvm use 16.13. 0 to easily switch into either version we need. Note that since we only have one version that begins with 12, 14, or 16, we can switch versions with a simple nvm use 16 , nvm use 14 , or nvm use 12 command.

Can we have two different version of node JS in the same system?

As on the same machine, we can only install one version of the nodejs, so it's very painful to uninstall and install the new node version as per your project requirements. To overcome this problem, we can use the Node Version Manager (NVM).

How do I know what version of pm2 node I have?

In pm2 , you can use the --interpreter options and specify the path to the node version you want. If you use n for version run n bin v4. 2.0 to get the path to this node version. Show activity on this post.

How do I change nodejs to downgrade?

Nodejs can be upgraded or downgraded using different methods some of them are by manually downloading the latest version of node from their official nodejs.org website and the second method is by using nvm which is really helpful in controlling the node version.


1 Answers

For later fellow googlers:

pm2 update

did help me in a similar case.

Found here: https://github.com/keymetrics/pm2-plus-tech-questions/issues/88

like image 94
Tobias Gepp Avatar answered Oct 16 '22 06:10

Tobias Gepp