nvm installation configuration and nodejs installation

The difference between nvm and npm

NVM(Node Version Manager) is a Node.js 版本管理器that allows you to install and switch multiple different versions of Node.js on the same computer at the same time. This is useful for developers who need to use different versions of Node.js in different projects.

NPM(Node Package Manager) is for Node.js 包管理器, used to manage and distribute various packages and modules required by Node.js applications. Through NPM, developers can easily install, upgrade, uninstall and share various components required by Node.js applications.

In simple terms, NVM is mainly used to control the Node.js version, while NPM focuses on managing various packages and modules required by Node.js applications.

nvm install

① First check whether nodejs is installed, open the terminal and enter the command node -v, and see the version number, indicating that node is installed. If node is not installed, skip directly to step ④.

② If you have installed node, first delete all the things about node.js in the computer.

③ Check whether the node is deleted: open the terminal and enter the command node -v, but the version number cannot be seen and an error is reported, indicating that the deletion is successful.

④ Download and install, open the official website to download the official nvm.

⑤ After installing nvm, check whether the installation is successful: open the terminal and enter the command nvm version, if you see the version number, it means the installation is successful.

install node

① Find the nvm installation directory and open settings.txt . Copy and paste the following two lines of code into the settings.txt file. As shown in the picture below, then save.

node_mirror: https://npmmirror.com/mirrors/node/
npm_mirror: https://npmmirror.com/mirrors/npm/

② Select the Node.js version to be installed, and use nvm install <version>the command to install it. version refers to the specific version number installed. For example nvm install 14.17.6, install v14.17.6 of Node.js.

③ After the installation is complete, you can use nvm use <version>the command to switch between different versions of Node.js

④ Use nvm lsto view all installed node versions, the one with an asterisk in front is the node version currently in use.

⑤ At this point, you may find that node is installed and the command is used nvm use, but there is no signal in front of any version, and an error node -vwill be reported when typing in the terminal. This is because node needs to configure environment variables. See the previous document for the configuration process. After the configuration is complete, you can use node normally.

Guess you like

Origin blog.csdn.net/weixin_52797317/article/details/129715964