zoukankan      html  css  js  c++  java
  • yarn命令的使用说明及.yarnrc使用等

    原文链接: https://blog.csdn.net/m0_37148591/article/details/82715339

    yarn/npm 命令

    概述

    通过 yarn add 添加依赖会更新 package.json 以及 yarn.lock 文件

    yarn add <packageName> // 依赖会记录在 package.json 的 dependencies 下在 package.json 中。
    
    
    yarn add <packageName> --dev 依赖会记录在 package.json 的 devDependencies 下   
    yarn add webpack --dev // yarn 简写 -D   
    npm install webpack --save-dev // npm
    
    yarn global add <packageName> 全局安装依赖   
    yarn global add webpack // yarn   
    npm install webpack -g // npm
    

     

    更新依赖

    yarn upgrade 用于更新包到基于规范范围的最新版本

    yarn upgrade // 升级所有依赖项,不记录在 package.json 中
    npm update // npm 可以通过 ‘--save|--save-dev’ 指定升级哪类依赖
    yarn upgrade webpack // 升级指定包
    npm update webpack --save-dev // npm
    yarn upgrade --latest // 忽略版本规则,升级到最新版本,并且更新 package.json
    

      

     

    移除依赖

    yarn remove <packageName>
    yarn remove webpack // yarn
    npm uninstall webpack --save // npm 可以指定 --save | --save-dev
    

     

    安装webpack.json中的所有文件

    yarn 或者 yarn install
    
    yarn install // 或者 yarn 在 node_modules 目录安装 package.json 中列出的所有依赖
    npm install // npm
    
    # yarn install 安装时,如果 node_modules 中有相应的包则不会重新下载 --force 可以强制重新下载安装
    yarn install --force // 强制下载安装
    npm install --force // npm
    

      

    运行脚本

    yarn <package.json 中 scripts 属性下定义的命令>
    

     

    显示某个包信息

    yarn info <packageName> 可以用来查看某个模块的最新版本信息
    
    yarn info webpack // yarn 
    npm info webpack // npm
    
    yarn info webpack --json // 输出 json 格式
    npm info webpack  --json // npm
    
    yarn info webpack readme // 输出 README 部分
    npm info webpack readme
    

      

    列出项目的所有依赖

    yarn list
    
    yarn list // 列出当前项目的依赖
    npm list // npm
    
    yarn list --depth=0 // 限制依赖的深度 ??
    sudo yarn global list // 列出全局安装的模块
    

      

     

    管理 yarn 配置文件 ??

    yarn coinfig
    
    yarn config set key value // 设置
    npm config set key value
    
    yarn config get key // 读取值
    npm config get key
    
    yarn config delete key // 删除
    npm config delete key
    
    yarn config list // 显示当前配置
    npm config list
    
    yarn config set registry https://registry.npm.taobao.org // 设置淘宝镜像
    npm config set registry https://registry.npm.taobao.org // npm
     

    .yarnrc

    配置淘宝镜像源
    项目根目录下添加文件.yarnrc,内容如下:

    registry "https://registry.npm.taobao.org"
    
    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"
    

      

    其中registry “https://registry.npm.taobao.org“就是指定淘宝镜像源,是最重要的。其余是指定对应包的下载路径
    添加文件且编辑结束后再使用yarn add命令就是从配置的镜像源中拉取需要的包,速度会更快。

    yarn-lock

    yarn-lock作用说明

  • 相关阅读:
    iOS 证书错误 Certificates下面的 App Store and Ad Hoc是灰的?? 点不了
    iOS 发布证书错误 Your build settings specify a provisioning profile with the UUID, no provisioning profile was found
    不能修改“System Roots”钥匙串 即下载的.cer 文件添加不到钥匙串
    修改 “嗨加游-Prefix.pch” 或者 “嗨加游-Info.plist ” 方法
    Java基础1(2015-8-2)
    认识modernizr----前端
    VS2013的C#项目与SQL Server2012无法连接的问题
    安装完SQL Server 2012后,由Windows身份验证设置为混合型的身份验证
    C#项目,在controller文件夹右击鼠标没有“添加控制器”的问题
    复制已存在的数据库结构(不包括库中的数据)
  • 原文地址:https://www.cnblogs.com/dfyg-xiaoxiao/p/13565271.html
Copyright © 2011-2022 走看看