Skip to content

Instantly share code, notes, and snippets.

@chranderson
Last active May 3, 2024 07:06
Show Gist options
  • Save chranderson/b0a02781c232f170db634b40c97ff455 to your computer and use it in GitHub Desktop.
Save chranderson/b0a02781c232f170db634b40c97ff455 to your computer and use it in GitHub Desktop.
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node
nvm install 18.16.1
// set default version of node
nvm alias default 18.16.1
// switch version of node
nvm use 20.5.1
// install latest LTS version of node (Long Term Support)
nvm install --lts
// install latest stable version of node
nvm install stable
@tasnuva1
Copy link

//////////// For Basic use //////////// 

// check version
node -v || node --version

// list installed versions of node (via nvm)
nvm ls

// To list available remote versions on Windows 10 you can type
nvm list available

// install a specific version of node
nvm install 6.9.2

// switch version of node
nvm use 6.9.1

@stevemosiori
Copy link

Thanks buddy!!

@RicardoGralhoz
Copy link

For more commands, try nvm --help

@RicardoGralhoz
Copy link

Example:

  • nvm install 8.0.0 Install a specific version number

  • nvm use 8.0 Use the latest available 8.0.x release

  • nvm run 6.10.3 app.js Run app.js using node 6.10.3

  • nvm exec 4.8.3 node app.js Run node app.js with the PATH pointing to node 4.8.3

  • nvm alias default 8.1.0 Set default node version on a shell

  • nvm alias default node Always default to the latest available node version on a shell

  • nvm install node Install the latest available version

  • nvm use node Use the latest version

  • nvm install --lts Install the latest LTS version

  • nvm use --lts Use the latest LTS version

  • nvm set-colors cgYmW Set text colors to cyan, green, bold yellow, magenta, and white

Note:
to remove, delete, or uninstall nvm - just remove the $NVM_DIR folder (usually ~/.nvm)

@Armalon
Copy link

Armalon commented Mar 18, 2021

What about
nvm uninstall <version>
or to remove, delete, or uninstall nvm - just remove the $NVM_DIR folder (usually ~/.nvm)

@deepak-r
Copy link

deepak-r commented Apr 3, 2021

Compiled all the commands in one place. Hope this helps.

Install Node

nvm install <node_version>      // Install a specific Node version
nvm install node                // Install latest Node release (Current)
nvm install --lts               // Install latest LTS release of NodeJS
nvm install-latest-npm          // Install latest NPM release only

List Available Node Releases

nvm ls-remote
nvm ls-remote | grep -i "latest"        
nvm ls-remote | grep -i "<node_version>"

List Installed Nodes

nvm list node                   // Lists installed Node versions
nvm list  (or)  nvm ls          // Lists installed Node versions with additional release info

Switch To Another Node Version

nvm use node                      // Switch to the latest available Node version
nvm use <node_version_or_alias>  // Switch to a specific version
nvm use --lts                    // Switch to the latest LTS Node version

Verifying Node Version

node -v  (or)  node --version
npm -v   (or)  npm --version
nvm -v   (or)  nvm --version

Set Alias

nvm alias default node                  // Always defaults to the latest available node version on a shell
nvm alias default <node_version>        // Set default node version on a shell
nvm alias <alias_name> <node_version>   // Set user-defined alias to Node versions 

nvm unalias <alias_name>                // Deletes the alias named <alias_name>

Path to Node Executable

nvm which <installed_node_version>      // path to the executable where a specific Node version is installed

Uninstall Specific Node Version

nvm uninstall <node_version>    // Uninstall a specific Node version
nvm uninstall --lts             // Uninstall the latest LTS release of Node
nvm uninstall node              // Uninstall latest (Current) release of Node

Uninstall NVM

 To remove, delete, or uninstall nvm, just remove the $NVM_DIR folder (usually ~/.nvm)

@fatfish516
Copy link

To list available remote versions on Windows 10 you can type:

nvm list available

Very very thanks~

@jbb26354
Copy link

....but none of these are the command that shows the latest development version of node. So, I'm assuming that in my ZSHRC I need to add a screen scrape of the home page to get the latest development version, then nvm install it.

@yuis-ice
Copy link

yuis-ice commented Feb 3, 2022

Thanks mate.

@codforc
Copy link

codforc commented Oct 20, 2022

//////////// For Basic use //////////// 

// check version
node -v || node --version

// list installed versions of node (via nvm)
nvm ls

// To list available remote versions on Windows 10 you can type
nvm list available

// install a specific version of node
nvm install 6.9.2

// switch version of node
nvm use 6.9.1

great!

@mi-martinez
Copy link

Compiled all the commands in one place. Hope this helps.

Install Node

nvm install <node_version>      // Install a specific Node version
nvm install node                // Install latest Node release (Current)
nvm install --lts               // Install latest LTS release of NodeJS
nvm install-latest-npm          // Install latest NPM release only

List Available Node Releases

nvm ls-remote
nvm ls-remote | grep -i "latest"        
nvm ls-remote | grep -i "<node_version>"

List Installed Nodes

nvm list node                   // Lists installed Node versions
nvm list  (or)  nvm ls          // Lists installed Node versions with additional release info

Switch To Another Node Version

nvm use node                      // Switch to the latest available Node version
nvm use <node_version_or_alias>  // Switch to a specific version
nvm use --lts                    // Switch to the latest LTS Node version

Verifying Node Version

node -v  (or)  node --version
npm -v   (or)  npm --version
nvm -v   (or)  nvm --version

Set Alias

nvm alias default node                  // Always defaults to the latest available node version on a shell
nvm alias default <node_version>        // Set default node version on a shell
nvm alias <alias_name> <node_version>   // Set user-defined alias to Node versions 

nvm unalias <alias_name>                // Deletes the alias named <alias_name>

Path to Node Executable

nvm which <installed_node_version>      // path to the executable where a specific Node version is installed

Uninstall Specific Node Version

nvm uninstall <node_version>    // Uninstall a specific Node version
nvm uninstall --lts             // Uninstall the latest LTS release of Node
nvm uninstall node              // Uninstall latest (Current) release of Node

Uninstall NVM

 To remove, delete, or uninstall nvm, just remove the $NVM_DIR folder (usually ~/.nvm)

@billcodycloud
Copy link

Great!

@amalikmuhd
Copy link

So helpful!

@shadab1301
Copy link

Great !!

@Nahidnawaz123
Copy link

set default node version-------------------

nvm set default node.js version 16.14.2

$ nvm alias default 16.14.2
$ nvm use node vx.x.x

$ node -v

v16.14.2

nvm install 8.0.0 Install a specific version number

nvm use 8.0 Use the latest available 8.0.x release

nvm run 6.10.3 app.js Run app.js using node 6.10.3

nvm exec 4.8.3 node app.js Run node app.js with the PATH pointing to node 4.8.3

nvm alias default 8.1.0 Set default node version on a shell

nvm alias default node Always default to the latest available node version on a shell

nvm install node Install the latest available version

nvm use node v.x.y.z - Use the latest version

nvm install --lts Install the latest LTS version

nvm use --lts Use the latest LTS version

nvm set-colors cgYmW Set text colors to cyan, green, bold yellow, magenta, and white

@ReactJaswanth
Copy link

Super and executed perfectly. Thank You guys

@pasokoner
Copy link

This is so helpful. Thanks

@augusto-dmh
Copy link

// To install the lts version for an specific major version
nvm install --lts=(major-version)

example: nvm install --lts=gallium (to install the lts for major version 16)

@tresorama
Copy link

tresorama commented Oct 14, 2023

# install last LTS version and install global packages from "current" node version.
# run "nvm list" to see if you have "current" alias and which version points to
nvm install --lts --reinstall-packages-from=current

# install specific version and install global packages from specific version
nvm install 20.0.0 --reinstall-packages-from=18

@Amjesh
Copy link

Amjesh commented Dec 20, 2023

Explore a comprehensive list of NVM commands by clicking on the text below. -
Screenshot 2023-12-20 at 1 34 30 PM

@HishamMubarak
Copy link

Thank you 🙏

@gedharizka
Copy link

very use full, thank you

@inzamam-reachfirst
Copy link

inzamam-reachfirst commented Feb 9, 2024

nvm alias default 18.19.0 command is not changing the default node version on wsl.

@singhamjesh
Copy link

singhamjesh commented Feb 9, 2024

Is this version installed on your machine?
Check your default node version using "nvm alias default"

@inzamam-reachfirst
Copy link

nvm -v is 0.39.7. I have installed node version 14 and v18 via nvm. The nvm alias default command does not change the node version and only defaults to v14. However, the command nvm use default 18.19.0 is working but when restarting WSL it falls back to v14.21.3.

Screenshot 2024-02-09 092438

@tresorama
Copy link

nvm -v is 0.39.7. I have installed node version 14 and v18 via nvm. The nvm alias default command does not change the node version and only defaults to v14. However, the command nvm use default 18.19.0 is working but when restarting WSL it falls back to v14.21.3.

Screenshot 2024-02-09 092438

Try command which node.
it gives you the path of the node binary currently active.
Check that ".nvm" is present on the path.

This is mine
Schermata 2024-02-10 alle 02 49 27

@inzamam-reachfirst
Copy link

inzamam-reachfirst commented Feb 12, 2024

nvm is present in which node command.

Screenshot 2024-02-12 115735

@tresorama
Copy link

From the screenshot your machine load node 18 and not node14, so it seem that is resolved. Is it the case ??

@inzamam-reachfirst
Copy link

It changes the node version but after closing the terminal or vs code, it reverts to node v14. The nvm alias default command is not working on WSL.

@tresorama
Copy link

It changes the node version but after closing the terminal or vs code, it reverts to node v14. The nvm alias default command is not working on WSL.

You don't have current alias. Maybe is this ...
Try this

# create alias named "current" that points to "default" aliased version
nvm alias current default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment