一、背景

机器:windows电脑

系统:Ubuntu子系统

二、下载 nvm

1.进入Ubuntu子系统

mkdir nvm

cd nvm/

2.安装nvm

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
提示内容:
=> Downloading nvm from git to '/home/lipeng/.nvm'
=> Cloning into '/home/lipeng/.nvm'...
remote: Enumerating objects: 278, done.
remote: Counting objects: 100% (278/278), done.
remote: Compressing objects: 100% (245/245), done.
remote: Total 278 (delta 31), reused 101 (delta 20), pack-reused 0
Receiving objects: 100% (278/278), 142.25 KiB | 746.00 KiB/s, done.
Resolving deltas: 100% (31/31), done.
=> Compressing and cleaning up git repository

=> Appending nvm source string to /home/lipeng/.bashrc
=> Appending bash_completion source string to /home/lipeng/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

3.设置环境

按照提示,直接 copy 以上最后三行指令

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

4.确认 nvm,返回结果:nvm

command -v nvm

查看nvm版本,
nvm -v

有以上内容说明安装成功

5.安装 nodejs

安装最新版:nvm install node

安装指定版:nvm install v8.11.3

查看已安装node列表:


nvm ls


切换node版本:


nvm use 14.19.1


https://blog.csdn.net/weixin_30569153/article/details/99782246?spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2.pc_relevant_default&utm_relevant_index=5


您已经阅读00:00:00欢迎留言评论,喜欢的话就为作者点个赞或者赏颗糖吧! 分享