nvm install node, configure yarn, cnpm

nvm install node, configure yarn, cnpm

nvm

  • what is it The version management tool of nodejs, in order to solve the incompatibility of various versions of node.js, you can use it to install and switch different versions of node.js
  • Important: Completely uninstall local node
  • download link
    insert image description here
  • After the uninstallation is complete, click nvm-setup.exe to install
    insert image description here
    insert image description here
    insert image description here
    and confirm the installation

node

nvm -v # 查看 nvm 版本号
nvm install 16.14.0 # 安装 node 指定版本
nvm ls # 查看 nvm 安装的所有版本【其中带 * 就是当前 node 版本】
nvm use 16.14.0 # 使用指定版本 node
  • Find the settings.txt file in the nvm installation directory, add the following code, and save itinsert image description here
node_mirror:https://npm.taobao.org/mirrors/node/
npm_mirror:https://npm.taobao.org/mirrors/npm/
  • Find [Advanced System Settings] - [Environment Variables] and the following environment will be automatically generated. If the following two sentences are not added --> OK
    insert image description here

yarn

First configure the global installation path.
Because nvm is used to manage node, and each version of nodejs comes with npm, so every time you switch the node version, the npm version will also switch, which may cause some other global packages that have been installed , causing the original downloaded package to be unavailable

  1. Configure the package path for global installation using -g when downloading packages with npm
npm config set prefix "D:\Nvm\nvm\npm

Then a .npmrc file will be generated under the user folder of the C drive (C:\Users[name]). After opening it with Notepad, you can see the following content 2. Add D:\Nvm\ to the path in the system environment
insert image description here
variable nvm\npm so that the npm package command can be installed globally

Note that after configuring the environment variables, you must click all the OK buttons to exit the environment variable settings, and then reopen a cmd window to take effect.
insert image description here
3. Install yarn

npm install yarn -g
yarn -v

insert image description here

In order to avoid conflicts with the yarn command of big data, I changed the front-end yarn command to yarn-front
insert image description here

cnpm

npm install -g cnpm
cnpm -v

insert image description here

Guess you like

Origin blog.csdn.net/weixin_43344151/article/details/130460399