I'm running PM2 list on MacOS, and those projects node are running of the nvm
managed node version. by right the expectation on the versioning
column it should be showing individual node process version based on their package.json version number respectively.
but it's showing the version of nvm
(node version manager). which is odd. Anyone has a clue or is this a bug from PM2 ? It happens for the couple of teammate who are working on MacOS either.
I finally understand the logic how pm2
works.
the current setup node was managed by nvm
and pm2
is installed globally inside the node version.
when those process above was started by using the following style:
{
...
script: 'npm',
args: 'run start:auth'
...
}
in the pm2 config.js (start script), it indirectly ask PM2 to refer to the nvm folder, to use the npm
there. at such when we inspect the process by invoking pm2 info auth
it shows this line, this gave us the hint, pm2 would read the package.json
resides in the ~/.nvm
folder, thus it becomes the version from nvm.
Therefore the mystery is resolved.
NOTE: PM2 would read the first available package.json
from the repository root
, or somewhere available within the script path
(e.g. when we do the pm2 info <process>
). with that said, in normal circumstance we only use pm2 in a production environment, and we tend to use it to start the actual *.js script, and it would process the package.json correctly without any issues.