Get into the habit of writing together! This is the 9th day of my participation in the "Nuggets Daily New Plan · April Update Challenge", click to view the details of the event .
We all know that many popular frameworks on the Internet basically follow 前后端
the route of separation, which means that most programmers have to accept front-end technologies, such as: vue
, react
etc. front-end frameworks ! ! ! ^_^
As we develop more projects, different projects use different frameworks, and there are also 本地开发环境
equivalent restrictions, such as node
version restrictions, this is a comparison 头疼
problem.
E.g:
- Project A, needs to be in v10.5.0
- Project B, needs to be in v12.16.1
That's disgusting for developers! ! ! =_=
If I want to run project A, I have to switch to node 10.5.0
version; to run project B, I have to switch to node 12.16.1
version. This 切换工作
, you have to 重新
install node! ! ! =_=
If you do this every time, you shouldn't be a waste of time! ! ! =_=
As one 牛皮的程序员
, why can't we do this! ! !
According to what you said 切换
, how can this be done in a comparatively 快捷
way?
Not much nonsense, there must be, it is the protagonist nvm
tool we are going to share today.
nvm
The tool is a node
version management tool that can help us quickly switch the local development environment node的版本
.
nvm install
1. Download nvm
1. Download address
From github
above, download the latest version: download address
Here, how do we choosenvm-setup.zip
注:本文下载版本:1.1.9(目前最新,目前时间2022-04-09)
2.安装nvm
解压安装:nvm-setup.zip
,一步步安装即可,不需要改什么东西!!!(这很关键)
打开cmd,输入nvm
命令,看到以下信息,表示已经安装成功了
注意:安装的时候,建议用默认的安装路径即可,不建议修改安装路径,否则会导致某些问题。不按照建议做的,后果自己承担哈!!!
二、配置加速镜像
因为nvm默认的下载地址,使用的是一个外国的地址,速度比较慢呀,这个是不能忍的啦!!!
咋们这里切换到淘宝的镜像
,下载速度快到你不可信喔!!!^_^
配置方法:
打开nvm的安装路径,默认安装路径是:C:\Users\Administrator\AppData\Roaming\nvm
对settings.txt,进行修改,后面加上淘宝的node
和npm
镜像地址即可
root: C:\Users\Administrator\AppData\Roaming\nvm
path: C:\Program Files\nodejs
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
复制代码
三、安装node
1.nvm安装命令:
nvm install v10.5.0
复制代码
这里是因为npm无法下载,导致安装失败了。可能是github的地址不太稳定导致。
好家伙,npm
安装失败了,这可咋整?别急,这里哥们还是有办法解决,接着往下!!!
这里分析一下,nvm下载的node
,就会放到这个路径下面,那咋们岂不是可以自己下载node,然后放入到这个路径下,nvm就可以进行管理node的版本呢?好像就是这样...
那么这样的话,我们手动下载node,放入到这个路径下,不就好了?
手动下载nodejs10.5.0
因为node10.5.0通过nvm安装失败了,我们得清一下这个有问题的node
卸载命令:
nvm uninstall 10.5.0
复制代码
同时把temp
也删了
Then, unzip it directly node-v10.5.0-win-x64.zip
and change the folder name tov10.5.0
Finally look at the effect:
nvm list //列出所有node版本
复制代码
Good guy, this way nvm
you can manage this too node10.5.0
, Niu Niu Niu! ! ! ^_^
Switch to use the specified version of node
nvm use 10.5.0
复制代码
nodejs
A star here indicates the version currently in use
In the same way, let's proceed to install: 12.16.1
and16.14.0
The download address of the historical version of nodejs
switch to16.14.0
View node
, npm
version, normal use
See, switching is so easy, 丝滑
ah! ! ! Perfect! ! ! ^_^
To summarize the nvm command:
Order | effect |
---|---|
nvm list | List all node versions |
nvm use 10.5.0 | Switch the specified version of node |
nvm install v10.5.0 | Install the specified node version |
nvm uninstall v10.5.0 | Uninstall the specified node version |
Well, that's all for the basic installation and operation of nvm, and we can write code happily! ! ! ^_^