npm 手册

1. 安装npm包

npm install jquery --save

2. 更新一个npm包

npm update jquery --save

3. 删除一个包

npm uninstall jquery --save

4. 安装指定版本的npm包

npm install jquery@2.2.4 --save

5. npm更新到最新

npm install npm@latest -g

6. npm降低版本

npm install npm@4 -g

7. 快速删除node_modules

npm install rimraf -g
rimraf node_modules

8. 报错:Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 8.x 如何处理?

npm rebuild node-sass
npm update

9. 报错:npm ERR! Error: EPERM: operation not permitted, rename 如何处理?

管理员模式运行cmd即可

10.使用淘宝镜像

  1. 临时使用
npm --registry https://registry.npm.taobao.org install koa
  1. 持久使用
npm config set registry https://registry.npm.taobao.org
  1. 通过cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org

11. 使用官方镜像

npm config set registry https://registry.npmjs.org/

12. 查看npm源地址

npm config get registry