node.js 和 npm/cnpm/nrm 的安装

node.js 和 npm/cnpm/nrm 的安装

  • 安装 node.js。去 官网 下载,下载 LTS 版本的。安装时一路点确定,不要改动任何设置。
  • 在 git-bash 或是 cmd 下,输入 node -v,查看 node 的版本,检验 node 是否安装成功。然后输入 npm -v,查看 npm 的版本。 node.js 内置了 npm。
  • 淘宝 NPM 镜像官网,在“使用说明”一栏下复制这一句
1
npm install -g cnpm --registry=https://registry.npm.taobao.org

在命令行下运行。以后就可以用 cnpm 代替 npm 来进行包的安装了。

  • cnpm 的使用
1
2
3
cnpm install [name] // cnpm 安装模块

cnpm sync connect // cnpm 同步模块,只有 cnpm 命令行才有此功能
1
2
3
4
5
6
7
8
9
npm install -g nrm
或是用 cnpm 安装
cnpm install -g nrm

nrm -V // 查看 nrm 的版本
nrm ls // 展示所有可用的镜像源
nrm us 大专栏  node.js 和 npm/cnpm/nrm 的安装e taobao // switch registry to taobao 使用淘宝镜像源
nrm use cnpm // switch registry to cnpm 即切换镜像源
nrm test // 测试所有镜像源的速度

在 windows 下升级 node.js

  • 官网 下载新版本 .msi 安装程序
  • 下载完成后双击安装程序,进行安装
  • 安装目录要与电脑上原有的 node.js 的安装目录相同,例如原有的 node.js 安装目录为 “C:Program Files(x86)nodejs”,则安装新版时,安装目录也要是 “C:Program Files(x86)nodejs”
  • 安装完成后,查看 node.js 和 npm 的版本
1
2
node -v
npm -v

升级 npm

1
npm install -g npm

另一个包管理工具

参考链接

原文地址:https://www.cnblogs.com/lijianming180/p/12026685.html