Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

f1yn
Copy link

@f1yn f1yn commented Jul 1, 2023

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) ✓

@CLAassistant
Copy link

CLAassistant commented Jul 1, 2023

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants