nvm-----node version manager

Use nvm to switch between different node versions

We have a lot of new and old projects when we are developing. Some old projects will require the use of a lower version of node, but new projects will require a higher version of node. At this time, it is very tangled. Because if you start a low-version project with a high-version node, it will fail to start or cause memory overflow when the code is saved (this problem can be solved by referring to other articles, but I found that none of the solutions I found can solve it). So it is to use nvm to manage the version

First look at the official website documentation: https://nvm.uihtm.com/

This can be downloaded and installed tutorials,

Network disk address: https://pan.baidu.com/s/12E7d46XLVxGOmTDevVB58g?pwd=ntfm

insert image description here

1. Uninstall the original node version of the computer before installation, and then use the installation package to install

The installation process can be seen on the official website, that is, the installation location, etc.

insert image description here

This is a successful installation

2. Switch the source and set the mirror image. We generally use Taobao. It's better to switch the source now, and then install other things, so it's faster

You can use the command line to add, or add directly under the nvm installation directory (settings.txt file in the nvm directory)

//直接文件添加
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/

//命令行
nvm npm_mirror https://npmmirror.com/mirrors/npm/
nvm node_mirror https://npmmirror.com/mirrors/node/

insert image description here

3. Install different versions of node

nvm install 版本号

4. Switch unused node usage

//先查看安装的node列表
nvm ls

//切换16.14.2
nvm use 16.14.2

insert image description here

Well, the above is over, but when you are excited to operate, you find a bunch of problems to solve! ! !
Pitfalls:
1. When switching between high and low versions, the npm prompt is too high or too low to use. The
online saying is to download the npm corresponding to node by yourself, and then put the package in the node file under nvm to replace it. I tried it , but it doesn't seem to work, how to solve it in the end, I forgot! ! ! ! ! ! ! !

2. It will remind that vue -v is not an internal command, npm -v is not an internal command
, but in fact, if you operate normally, it will not be like this, and it can be displayed normally!
The high probability is the problem of environment variables

nvm command prompt

  • nvm arch: Shows whether node is running on 32-bit or 64-bit.
  • nvm install <version> [arch]: Install node, version is a specific version or the latest stable version latest. The optional parameter arch specifies whether to install the 32-bit or 64-bit version, and the default is the system bit. --insecure can be added to bypass SSL for remote servers.
  • nvm list [available]: Display the installed list. The optional parameter available displays all versions that can be installed. list can be simplified to ls.
  • nvm on: Enable node.js version management.
  • nvm off: Turn off node.js version management.
  • nvm proxy [url]: Set download proxy. Without the optional parameter url, the current proxy is displayed. Setting url to none removes the proxy.
  • nvm node_mirror [url]: Set node mirroring. The default is https://nodejs.org/dist/. If no url is specified, the default url will be used. After setting, you can go to the settings.txt file in the installation directory to view it, or you can directly operate in this file.
  • nvm npm_mirror [url]: Set up npm mirroring. https://github.com/npm/cli/archive/. If no url is specified, the default url will be used. After setting, you can go to the settings.txt file in the installation directory to view it, or you can directly operate in this file.
  • nvm uninstall <version>: Uninstall the specified version node.
  • nvm use [version] [arch]: Use the specified version node. 32/64 bits can be specified.
  • nvm root [path]: Set the directory where different versions of node are stored. If not set, the current directory is used by default.
    e. 32/64 bits can be specified.
  • nvm root [path]: Set the directory where different versions of node are stored. If not set, the current directory is used by default.
  • nvm version: Display nvm version. version can be simplified to v.

Guess you like

Origin blog.csdn.net/lu6545311/article/details/132334874