我是靠谱客的博主 不安宝贝,这篇文章主要介绍使用yarn代替npm,现在分享给大家,希望可以做个参考。

使用yarn代替npm

1.我们在安装完node之后就有了npm,但是我们嫌弃比较慢,于是就使用了淘宝NPM镜像cnpm
安装cnpm命令:

复制代码
1
npm install -g cnpm --registry=https://registry.npm.taobao.org

2.我们嫌弃cnpm路径问题以及丢包问题,更改npm仓库。具体命令:

复制代码
1
2
npm config set registry https://registry.npm.taobao.org --global npm config set disturl https://npm.taobao.org/dist --global

3.Nodejs中国镜像,为中国内地的Node.js开发者准备的镜像配置,大大提高node模块安装速度。

复制代码
1
2
3
4
5
# 从registry地址安装mirror-config-china npm i -g mirror-config-china --registry=https://registry.npm.taobao.org # 检查是否安装成功 如果安装成功之后会出现 userconfig C:Users{YOUNAME}.npmrc 这个里面写了很多镜像地址 npm config list

4.然后我们可以为项目生成镜像配置

复制代码
1
2
cd ~/my-project mirror-config-china --registry=https://registry.npm.taobao.org

5.重点来了,我们使用yarn

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 全局安装yarn npm install -g yarn # 同样,我们也为yarn设置镜像源 yarn config set registry https://registry.npm.taobao.org --global yarn config set disturl https://npm.taobao.org/dist --global # 安装完 yarn 之后就可以用 yarn 代替 npm 了,例如用 yarn 代替 npm install 命令,用 yarn add 某第三方库名代替 npm install 某第三方库名。 # 为了更好用,顺便我们再多配置点东西 phantomjs_cdnurl=https://bitbucket.org/ariya/phantomjs/downloads sass_binary_site "https://npm.taobao.org/mirrors/node-sass/" phantomjs_cdnurl "http://cnpmjs.org/downloads" electron_mirror "https://npm.taobao.org/mirrors/electron/" sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/" profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/" chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"

转载于:https://www.cnblogs.com/marvelousone/p/11386436.html

最后

以上就是不安宝贝最近收集整理的关于使用yarn代替npm的全部内容,更多相关使用yarn代替npm内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(56)

评论列表共有 0 条评论

立即
投稿
返回
顶部