One, foreword

In our daily development, we often encounter several projects at hand, and each project runs in a different environment. Different projects must rely on different versions of NodeJS runtime environment. Every problem has to have a solution, so NVM came into being. Today xiaobian will take you to uncover the mystery of NVM, if it is helpful to you, you remember to praise attention, not miss every dry goods.

2. Get to know NVM

NVM(NodeJS Version Management) is a NodeJS Version Management tool. It allows you to install and switch between different versions of NodeJS.

Three, installation,

Be sure to uninstall the installed NodeJS before installation; otherwise, conflicts may occur.

3.1 Windows installation

Download the latest nVM-Windows installation package and install it directly.

  • Nvm-noinstall. zip: green installation-free version, which requires configuration.
  • Nvm-setup. zip: installation version, recommended

3.2 OS X/Linux Installation

  • The curl – o – raw.githubusercontent.com/creationix/… | bash
  • Wget – qO – raw.githubusercontent.com/creationix/… | bash

Install different versions of Node/Npm

Remember to uninstall the installed NodeJS before installation to avoid errors after installation

4.1. View all versions installed locally. The optional parameter available displays all downloadable versions.

nvm list [available]
Copy the code

4.2 Install. The version number in the command can be customized. For details, see command 1

NVM install 14.15.4Copy the code

4.3. Use a specific version

NVM use 14.15.4Copy the code

4.4, unloading

NVM uninstall 14.15.4Copy the code

4.5. You can list all available versions on the remote server by using the following command

  • OS X/Linux
nvm ls-remote
Copy the code
  • Windows
nvm ls available
Copy the code

5. Common commands

5.1 Switching the Version to 14.15.4

NVM use 14.15.4Copy the code

5.2 Switching to the latest version

nvm use node
Copy the code

5.3 Setting the alias to current-version

NVM alias current - version 14.15.4Copy the code

5.4 Canceling An Alias

nvm unalias current-version
Copy the code

5.5 Setting the Special alias default

nvm alias default node
Copy the code