1. 版本号

image.png

2 npm i和npm install

基本一样,但是有区别,推荐npm install

3 cnpm 使用

cnpm 不会lock版本,以及在node_moudule下生成_xxx包名,
要是想利用淘宝源,建议 npm install xxxx —registry=https://registry.npm.taobao.org

1.临时使用

npm —registry https://registry.npm.taobao.org install express

2.持久使用

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

3.通过cnpm

npm install -g cnpm —registry=https://registry.npm.taobao.org

4使用官方镜像

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

5 查看npm源地址

npm config get registry

4 npm script

同时参考本库linux-shelllinux-bash

5 pnpm

https://www.pnpm.cn/
节省磁盘空间并提升安装速度 | 创建非扁平的 node_modules 目录

6 yarn

6.1 切换到国内cnpm源

查看
yarn config get registry
切换
yarn config set registry https://registry.npmmirror.com

6.2 yarn link 调试开发阶段的包

参考: react源码调试

7 nrm - npm register manager

nrm can help you easy and fast switch between different npm registries, now include: npm, cnpm, taobao, nj(nodejitsu).以及私有仓库

  1. $ nrm ls
  2. $ nrm use cnpm
  3. //switch registry to cnpm Registry has been set to: http://r.cnpmjs.org/
  4. nrm add sinopia http://ip:4873
  5. nrm use sinopia
  6. npm install some-private-npm