Installation and use of node.js version management tool nvm

nvm installation and use

When we use a new front-end framework, we are often prompted that a tool requires a higher version of node.js, but some existing old projects need to rely on the old version of node.js. So nvm came into being, it is a tool specially used to manage node.js version. With it, we can use different versions in different projects, and we can also easily switch versions in the terminal to match different environments.

nvm installation

There is an installation tutorial in my other article "Installing Node.js on CentOS 7 Server" , which is the same installation on macOS. Here we only introduce the installation of macOS or linux, and you can find and install it yourself for windows.

nvm common operation commands

nvm on       #启用版本管理
nvm off      #禁用版本管理

nvm ls                  #查看本地 Node 版本
nvm ls-remote           #查看官网 Node 版本
nvm ls-remote --lts     #查看官网 Node LTS 版本

nvm current             #显示当前的版本
nvm install 10.16.2     #安装指定版本
nvm use 10.16.2         #使用指定版本
nvm alias default 10.16.2  #设置默认使用版本

nvm uninstall 10.16.2   #卸载指定版本

Demonstration of command execution results

nvm ls

nvm ls
At this point node -v outputs v18.12.0

nvm ls-remote

nvm ls-remote
All node.js versions will be output, here is only a small part of the screenshot

nvm ls-remote --lts

nvm ls-remote --lts
Will only filter out LTS versions

nvm use <v version number>

nvm use <v version number>

nvm alias default <version number>

nvm alias default <version number>
At this time, nvm ls can be used to view that the default version has been changed to the specified version
insert image description here

nvm current

nvm current
In the project, the above commands can generally meet the development needs.

Guess you like

Origin blog.csdn.net/zhouweihua138/article/details/129481533