nvm使用

2024/10/28 nvm 共 743 字,约 3 分钟

nvm

官网

https://github.com/nvm-sh/nvm

容易成功的方式

If you have git installed (requires git v1.7.10+):

  1. clone this repo in the root of your user profile
    • cd ~/ from anywhere then git clone https://github.com/nvm-sh/nvm.git .nvm
  2. cd ~/.nvm and check out the latest version with git checkout v0.40.1或者git chechkout v0.39.3
  3. activate nvm by sourcing it from your shell: ./nvm.sh 或者 install.sh

完成之后执行source ~/.bashrc才能生效

nvm安装命令

# 同时完成node和npm的安装
nvm install 14.7.0

安装完npm之后,最好添加npm的国内源,例如:

npm config set registry https://npm.aliyun.com/

参考:https://cloud.tencent.com/developer/article/2483466

pnpm的安装

完成nvm的安装之后,很容易通过nvm install 安装 node 和 npm,

安装完npm之后,很容易进行pnpm的安装

普通命令

npm install -g pnpm

卸载命令

npm uninstall -g pnpm

特定版本安装

npm install -g pnpm@x.x.x

yarn安装

npm install --global yarn
# 验证
yarn --version

总结

nvm->node and npm ->pnpm and npm ->yarn

文档信息

Search

    Table of Contents