yarn与npm命令

yarn的安装
npm install -g yarn
安装完成之后查看版本
yarn -v 或 yarn --version
常用命令
yarn info #显示某个包信息
yarn list # 列出当前项目的依赖
yarn list --depth=0 # 限制依赖的深度
yarn config set key value # 设置
yarn config get key # 读取值
yarn config delete key # 删除
yarn config list # 显示当前配置
yarn config set registry https://registry.npm.taobao.org # 设置淘宝镜像
yarn cache #缓存
yarn cache list # 列出已缓存的每个包
yarn cache dir # 返回 全局缓存位置
yarn cache clean # 清除缓存
与npm命令对比
yarnnpm命令说明
yarn initnpm init项目初始化
yarn installnpm instal安装默认依赖
yarn add reactnpm install react --save安装某个依赖,并保存到package.json中
yarn remove reactnpm uninstall react --save移除某个依赖
yarn add react --devnpm install react --save–dev安装某个开发时依赖
yarn upgrade reactnpm update react --save更新某个依赖
yarn global add reactnpm install react --global安装某个全局依赖
yarn run/testnpm run/test运行某个命令
使用时遇到的报错信息及解决方法(持续更新)

1、yarn安装模块时,出现错误

yarn add gulp-concat #输入
#输出
yarn add v1.22.10
info No lockfile found.
[1/4] Resolving packages...
error An unexpected error occurred: "http://registry.cnpmjs.org/gulp-concat: Hostname/IP does not match certificate's altnames: Host: registry.cnpmjs.org. is not in the cert's altnames: DNS:r.cnpmjs.org".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\XZC\\Desktop\\test\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

遇到这个问题是由于网络原因导致下载依赖包请求超时报错,更换网络下载即可,命令行输入:

npm config set registry https://registry.npm.taobao.org  
npm config set disturl https://npm.taobao.org/dist  
yarn config set sass-binary-site http://npm.taobao.org/mirrors/node-sass

最后重新安装成功!

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值