本章主要介绍npm。
1.1 简介
npm 是 Node.js 的包管理工具, 是世界上最大的开源库生态系统。
1.2 安装
新版的nodejs 已经集成了npm, 所以只需 安装nodeJS 即可
1.3 npm升级
- windows:
sudo npm install npm -g
- linux:
npm install npm -g
1.4 使用nrm切换npm源
npm是包管理工具, 官方默认npm源是 https://registry.npmjs.org/, 国内直接使用非常慢, 可以切换为国内的npm源, 使用nrm切换npm源非常方便。
- 安装nrm
npm install -g nrm
- 列出所有npm源
nrm ls
- 当前使用的npm源
nrm current
- 切换为淘宝npm源
nrm use https://registry.npm.taobao.org/
- 添加淘宝npm源
nrm add taobao https://registry.npm.taobao.org/
- 删除淘宝npm源
nrm del https://registry.npm.taobao.org/
- 测试淘宝npm源速度
nrm test https://registry.npm.taobao.org/
1.5 npm 命令
- 使用 npm 命令安装模块,命令中加上-g代表全局安装
npm install <Module Name> [-g]
- 卸载模块
npm uninstall <Module Name>
- 更新模块
npm update <Module Name>
- 搜索模块
npm search <Module Name>
文档信息
- 本文链接:http://www.duobab.com/2021/02/04/npm/
- 版权声明:转载请注明出处