pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

Added opt-in fnm support (as a nvm alternative)

Open f1yn opened this issue 2 years ago • 1 comments

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #5505
License MIT
Doc PR https://github.com/pm2-hive/pm2-hive.github.io/pulls

Several months ago, I brought up how I wanted to use a node version other than nvm with PM2. No feedback was given, and several months later I'm re-installing my environment and I was faced with the same issue.

This adds fnm support when PM2_USE_FNM is detected in the environment. Instead of using nvm it will opt to use a the fnm flow. There's some pretty ancient code in the common file - so I opted to use some saner syntax when possible.

Installing (before this is merged)

I'm not sure how long I'll keep my fork up, but in the meantime you can use:

# npm
npm install f1yn/pm2#5485194
# yarn
yarn add f1yn/pm2#5485194

Example of using fnm instead of nvm

Earlier in environment:

export PM2_USE_FNM=1

When starting or stopping services:

$ dev start api
Using Node v16.15.0
[PM2] Spawning PM2 daemon with pm2_home=/home/flynn/.pm2
[PM2] PM2 Successfully daemonized
[PM2][WARN] Applications api not running, starting...
[PM2] Using fnm mode (via FNM_DIR)
[PM2] Setting Node to v16.13.2 (path=/home/flynn/.local/share/fnm/node-versions/v16.13.2/installation/bin/node)
[PM2] App [api] launched (1 instances)

What happened before:

$ dev start api
Using Node v16.15.0
raisely_postgres_1 is up-to-date
[PM2][ERROR] NVM is not available in PATH
[PM2][ERROR] Fallback to node in PATH
[PM2][ERROR] Install NVM:
$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
[PM2] Applying action restartProcessId on app [api](ids: [ 0 ])
[PM2] [api](0) ✓

f1yn avatar Jul 01 '23 00:07 f1yn

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 01 '23 00:07 CLAassistant