1、npm安装
NPM是随同NodeJS一起安装的包管理工具,因此在我们安装nodeJS的同时npm也被安装了,关于nodeJS的安装,需要的可以查看我的另外一篇文章,连接:https://blog.youkuaiyun.com/qq_33455771/article/details/81324391
检查npm是否安装成功以及npm的版本:
npm -v
2、npm更新
(1)npm install npm -g
(2)更新到最新版本:
npm install npm@latest -g
(3)更新到最新官方测试版本:
npm install npm@next -g.
3、番外(淘宝镜像cnpm)
因为 npm 的服务器在国外,当我们的网速不够好或者是在使用高峰期的时候,npm安装下载模块的速度是很慢的,因此促使了cnpm的诞生。
(1)安装cnpm。打开cmd,执行下面的命令:
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm的用法与npm一样。
(2) 临时使用cnpm
在你的项目中打开cmd,执行下面的命令
npm --registry https://registry.npm.taobao.org install express
注:install express 是你需要安装的模块
(3)持久使用
打开cmd,执行下面的命令:
npm config set registry https://registry.npm.taobao.org
验证cnpm是否安装成功
npm config get registry
截图:
或
npm info express
截图: