Inspired by pvm. An alternative to version managers like nvm or n.
Can currently install and switch between exact semantic versions, latest-of-major (ie: 18 -> 18.18.2) and lts code names (ie: lts/dubnium -> 10.24.1).
This is an early release and likely contains some bugs - please open an issue for any bugs you discover.
Feature request: open node docs from the command line with nnvm docs or nnvm docs <version>.
Example: https://nodejs.org/dist/latest-hydrogen/docs/api/
First, remove any currently-installed node versions and node version managers (especially nvm or anything installed via brew). Remove any node or version manager logic from your profile (~/.zshrc or ~/.bashrc or ~/.profile or ~/.bash_profile). You can detect node versions with which node and then rm the file, continuing until the command is not found.
Next, install nnvm:
curl -H 'Cache-Control: no-cache' -o- https://raw.githubusercontent.com/pkg-mgr/nnvm/main/setup.sh | bashAlternately, to auto-remove any existing node installation before installing:
curl -H 'Cache-Control: no-cache' -o- https://raw.githubusercontent.com/pkg-mgr/nnvm/main/setup.sh | NUKE_NODE=1 bashThis removes any existing node, npm and npx commands.
rm -rf ~/.nnvm /usr/local/bin/node /usr/local/bin/nnvm
# or simply:
nnvm nukeOnce nnvm is installed, you need to install at least one version of node (ex: nnvm install 8.9.2). You are now ready to use node. You can then install additional versions the same way and switch between them with nnvm use <version>.
You can also specify a default version (ex: nnvm default 8.9.5) for any new shell session where you have not run the nnvm use <version> command yet.
In addition, if you create a .nnvmrc file with a version in the same folder as a package.json file, any node command run in that folder will automatically use the specified version.
Example:
echo "8.9.2" > .nnvmrc
node --version(The .nnvmrc must be in the same directory as your project's package.json file.)
- Individual command scripts are installed to
~/.nnvm/cmdsfolder - node binaries are installed to
~/.nnvm/versionfolders (ex:~/.nnvm/8.9.2) - The
run.shscript is copied to/usr/local/bin/node. This allows us to intercept and run node commands with the correct version of node. - The
cmd.shscript is copied to/usr/local/bin/nnvmand/usr/local/bin/nnvm. This allows us to run the nnvm commands which collectively allow node version management.
Note: after running setup, you can run nnvm help to see the list of available commands.
nnvm defaultaka~/.nnvm/cmds/default.sh- lists the default version. (Initially set to the latest at time of original setup.)nnvm default <version>aka~/.nnvm/cmds/default.sh- sets the default node versionnnvm helpaka~/.nnvm/cmds/help.sh- lists all available commandsnnvm installaka~/.nnvm/cmds/install.sh- installs the latest version of nodennvm install <version>aka~/.nnvm/cmds/install.sh- installs specified node version.nnvm listaka~/.nnvm/cmds/list.sh- lists all currently installed versions of nodennvm list --remoteaka~/.nnvm/cmds/list.sh- lists all versions available to installnnvm nukeaka~/.nnvm/cmds/nuke.sh- removes nnvm and all node binaries completelynnvm runaka~/.nnvm/cmds/run.sh- runs a node command using automatic node version detection. (The node command will also do this directly.)nnvm uninstall <version>aka~/.nnvm/cmds/uninstall.sh- uninstalls specified node versionnnvm unuseaka~/.nnvm/cmds/unuse.sh- un-sets the node version for the current terminal sessionnnvm updateaka~/.nnvm/cmds/- updates all nnvm scriptsnnvm useaka~/.nnvm/cmds/use.sh- sets the node version for the current terminal session
- VS Code
- Code Spell Checker
- shellcheck via the VS Code Extension for script linting
- shell-format for auto-formatting
Make code changes, then run ./setup.sh which will perform setup using your local code. You can now test your local changes with using the nnvm command.
Once you've tested the commands locally, raise a PR. The changes are live once they are merged to master.