0%

NodeJS 相关镜像源设置

npm 查看镜像源

1
2
# npm config (set | get | delete | list | edit)
npm config get (registry|sass_binary_site)

使用

临时使用镜像

1
2
3
npm install --registry=https://registry.npmmirror.com pkg_name -g cnpm
# 创建别名
alias npmc="npm --registry=https://registry.npmmirror.com"

全局配置

1
2
3
# npm
npm config set registry https://registry.npm.taobao.org
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass/phantomjs_cdn

yarn 查看镜像源

1
2
# yarn config (set | get | delete | list | current)
yarn config get(registry|sass_binary_site)

使用

临时使用镜像

1
yarn add --registry=https://registry.npm.taobao.org

全局配置

1
2
yarn config set registry https://registry.npm.taobao.org -g
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g

yarn使用

1
2
3
4
5
6
7
8
9
10
11
12
13
# 初始化项目
yarn init [-y]
# 添加依赖
yarn [global] add
-D, --dev save package to your `devDependencies`(开发依赖)
-P, --peer save package to your `peerDependencies`(对等依赖)
-O, --optional save package to your `optionalDependencies`(可选依赖)
# 安装项目所有依赖 `yarn` or
yarn install [--update-checksums]
# 更新
yarn upgrade
# 移除
yarn remove