NVM

nvm是nodejs的版本管理工具,能够在一个环境中同时装置多个nodejs版本(和配套的npm版本),并随时切换。

下载与装置

  • 点击下载NVM
  • 解压后开始装置
  • 查看nvm装置版本

    nvm version

nvm下载太慢?

  • 查找nvm的装置门路

    where nvm
  • 在该门路下,找到setting.txt
  • setting.txt文件最初增加两句代码,查看参考

    node_mirror: https://npm.taobao.org/mirrors/node/npm_mirror: https://npm.taobao.org/mirrors/npm/
  • 保留setting.txt文件后,重启cmd继续执行其余操作

应用NVM装置NodeJs

  • 查看可用node版本

    nvm ls available
  • 依据理论需要,装置对应的node版本

    nvm install v12.12.0
  • 显示本地曾经装置的node版本

    nvm list
  • 应用指定版本的node,带星号是以后正在应用的版本

    • 如果执行呈现问题,请尝试以管理员权限运行cmd
    nvm use 12.12.0
  • 卸载指定的node版本

    nvm uninstall 12.12.0
  • 查看node版本

    node -v

镜像源

  • 查看以后应用的镜像源

    npm config get registry
  • 批改镜像源

    # 长期批改npm install 软件名 --registry https://registry.npm.taobao.org/# 全局批改npm config set registry https://registry.npm.taobao.org/也可应用nrm切换镜像源

NRM治理镜像源

  • 装置
    nrm不仅能够疾速切换镜像源,还能够测试本人网络拜访不同源的速度。

    npm install -g nrm
  • 列出以后可用的所有镜像源

    nrm ls    npm ---------- https://registry.npmjs.org/    yarn --------- https://registry.yarnpkg.com/    tencent ------ https://mirrors.cloud.tencent.com/npm/    cnpm --------- https://r.cnpmjs.org/    taobao ------- https://registry.npmmirror.com/    npmMirror ---- https://skimdb.npmjs.com/registry/
  • 应用淘宝镜像源

    nrm use taobao
  • 测试访问速度

    nrm test taobao

Node包管理器

cnpm

  • 装置cnpm

    npm install cnpm -gornpm install -g cnpm --registry=https://registry.npmmirror.com
  • 查看cnpm版本

    cnpm -v

yarn

  • 装置yarn

    npm install --global yarn
  • 查看yarn版本

    yarn -v

pnpm

  • vue3举荐的包管理工具
  • 装置应用时,请确认您的node版本 > 12.17.0

    npm install -g pnpm
  • 检测pnpm版本

    pnpm -v