Yarn 包管理工具


已经安装的

yarn add vue
vue@2.2.5

yarn add  element-ui -S 


yarn add bootstrap@4.0.0-alpha.6 --save
 
yarn add @ng-bootstrap/ng-bootstrap --save
ng-bootstrap 以指令 (directive) 的形式提供组件, 方便在 html 视图中使用, 选择器 (selector) 使用同一的前缀 ngb , 类名则统一使用 Ngb 前缀。

更详细的博客
http://www.open-open.com/lib/view/open1478485680274.html

yarn 原仓库 包下载不 稳定,需要设置仓库为 tnpm 或在 cnpm
yarn config set registry “https://registry.npm.taobao.org”

Yarn 包管理工具 介绍:

Facebook出的,因为 node自带的 npm 包管理工具有缺陷
似乎是它独有的特性--离线模式: 一次在线联网安装包,永久离线使用,无需再联网重复地下载

直接用 Yarn官网 的描述 : (注:查看官网的文档和下载安装包可能需要科学上网)

 

 

 
 
 
下载, 安装, 配置环境变量
下载
最新稳定版 v0.21.3(2017.3.18 最新),有候选发布版本 v0.22.0 
我把下载链接放在CSDN上

5M左右,不大

安装
一直下一步,我安装在C盘,因为我的node也是安装在那里。我不清楚安装在其他盘会不会影响到后面的操作,所以保险起见,安装在C盘
安装在  C:Program Files (x86)Yarnin


配置环境变量
这是为了告诉 cmd命令窗口 去 C:Program Files (x86)Yarnin 文件夹下执行yarn命令,具体的操作百度吧
我是用 在PATH里引用环境变量”  这种方式来配置的
 
验证是否安装成功:yarn --version
如果出现版本号,说明安装成功 且 环境变量配置正确
没有的话,极有可能是环境变量配置错误

使用:

官方文档截图

实际操作:
yarn init
先cd到你的项目的文件夹下
如果yarn命令不可用,检查一下环境变量是否配置正确
安装过程中,我什么都不写一直回车,全部用默认配置:


倒数第二行提示会在当前文件夹下生成如下 package.json 文件:
(此文件功能:描述项目的基本信息和依赖包的信息

yarn add jquery
注释  : " jquery 和 " jQuery " 似乎是不同的包,也就是说,包名区分大小写

yarn add jQuery
 
安装了两个包后,package.json 文件会自动变成这样:
 
看已经安装了的
yarn list
我标红色的是重点,不是报错
效果 3.26.2017:
yarn list v0.21.3
warning No license field

├─ @ng-bootstrap/ng-bootstrap@1.0.0-alpha.22
├─ ansi-regex@2.1.1
├─ ansi-styles@2.2.1
├─ async-validator@1.6.8
├─ babel-helper-vue-jsx-merge-props@2.0.2
├─ balanced-match@0.4.2
├─ block-stream@0.0.9
│  └─ inherits@~2.0.0
├─ bootstrap@4.0.0-alpha.6
│  ├─ jquery@>=1.9.1
│  └─ tether@^1.4.0
├─ brace-expansion@1.1.6
│  ├─ balanced-match@^0.4.1
│  └─ concat-map@0.0.1
├─ buffer-from@0.1.1
│  └─ is-array-buffer-x@^1.0.13
├─ buffer-shims@1.0.0
├─ builtins@1.0.3
├─ chalk@1.1.3
│  ├─ ansi-styles@^2.2.1
│  ├─ escape-string-regexp@^1.0.2
│  ├─ has-ansi@^2.0.0
│  ├─ strip-ansi@^3.0.0
│  └─ supports-color@^2.0.0
├─ commander@2.9.0
│  └─ graceful-readlink@>= 1.0.0
├─ concat-map@0.0.1
├─ core-util-is@1.0.2
├─ create-react-app@1.3.0
│  ├─ chalk@^1.1.1
│  ├─ commander@^2.9.0
│  ├─ cross-spawn@^4.0.0
│  ├─ fs-extra@^1.0.0
│  ├─ hyperquest@^2.1.2
│  ├─ semver@^5.0.3
│  ├─ tar-pack@^3.4.0
│  ├─ tmp@0.0.31
│  └─ validate-npm-package-name@^3.0.0
├─ cross-spawn@4.0.2
│  ├─ lru-cache@^4.0.1
│  └─ which@^1.2.9
├─ debug@2.6.3
│  └─ ms@0.7.2
├─ deepmerge@1.3.2
├─ duplexer2@0.0.2
│  ├─ readable-stream@~1.1.9
│  └─ readable-stream@1.1.14
│  │  ├─ core-util-is@~1.0.0
│  │  ├─ inherits@~2.0.1
│  │  ├─ isarray@0.0.1
│  │  └─ string_decoder@~0.10.x
├─ element-ui@1.2.5
│  ├─ async-validator@^1.6.6
│  ├─ babel-helper-vue-jsx-merge-props@^2.0.0
│  ├─ deepmerge@^1.2.0
│  └─ throttle-debounce@^1.0.1
├─ escape-string-regexp@1.0.5
├─ fs-extra@1.0.0
│  ├─ graceful-fs@^4.1.2
│  ├─ jsonfile@^2.1.0
│  └─ klaw@^1.0.0
├─ fs.realpath@1.0.0
├─ fstream-ignore@1.0.5
│  ├─ fstream@^1.0.0
│  ├─ inherits@2
│  └─ minimatch@^3.0.0
├─ fstream@1.0.11
│  ├─ graceful-fs@^4.1.2
│  ├─ inherits@~2.0.0
│  ├─ mkdirp@>=0.5 0
│  └─ rimraf@2
├─ glob@7.1.1
│  ├─ fs.realpath@^1.0.0
│  ├─ inflight@^1.0.4
│  ├─ inherits@2
│  ├─ minimatch@^3.0.2
│  ├─ once@^1.3.0
│  └─ path-is-absolute@^1.0.0
├─ graceful-fs@4.1.11
├─ graceful-readlink@1.0.1
├─ has-ansi@2.0.0
│  └─ ansi-regex@^2.0.0
├─ has-symbol-support-x@1.1.0
├─ has-to-string-tag-x@1.1.0
│  └─ has-symbol-support-x@^1.1.0
├─ hyperquest@2.1.2
│  ├─ buffer-from@^0.1.1
│  ├─ duplexer2@~0.0.2
│  └─ through2@~0.6.3
├─ inflight@1.0.6
│  ├─ once@^1.3.0
│  └─ wrappy@1
├─ inherits@2.0.3
├─ is-array-buffer-x@1.1.0
│  ├─ has-to-string-tag-x@^1.1.0
│  ├─ is-object-like-x@^1.1.0
│  └─ to-string-tag-x@^1.1.0
├─ is-function-x@1.1.0
│  ├─ has-to-string-tag-x@^1.1.0
│  ├─ is-primitive@^2.0.0
│  └─ to-string-tag-x@^1.1.0
├─ is-object-like-x@1.1.0
│  ├─ is-function-x@^1.1.0
│  └─ is-primitive@^2.0.0
├─ is-primitive@2.0.0
├─ isarray@0.0.1
├─ isexe@2.0.0
├─ jquery@3.2.1
├─ jsonfile@2.4.0
│  └─ graceful-fs@^4.1.6
├─ klaw@1.3.1
│  └─ graceful-fs@^4.1.9
├─ lodash.isnull@3.0.0
├─ lru-cache@4.0.2
│  ├─ pseudomap@^1.0.1
│  └─ yallist@^2.0.0
├─ minimatch@3.0.3
│  └─ brace-expansion@^1.0.0
├─ minimist@0.0.8
├─ mkdirp@0.5.1
│  └─ minimist@0.0.8
├─ ms@0.7.2
├─ once@1.4.0
│  └─ wrappy@1
├─ os-tmpdir@1.0.2
├─ path-is-absolute@1.0.1
├─ process-nextick-args@1.0.7
├─ pseudomap@1.0.2
├─ readable-stream@2.2.6
│  ├─ buffer-shims@^1.0.0
│  ├─ core-util-is@~1.0.0
│  ├─ inherits@~2.0.1
│  ├─ isarray@~1.0.0
│  ├─ isarray@1.0.0
│  ├─ process-nextick-args@~1.0.6
│  ├─ string_decoder@~0.10.x
│  └─ util-deprecate@~1.0.1
├─ rimraf@2.6.1
│  └─ glob@^7.0.5
├─ semver@5.3.0
├─ string_decoder@0.10.31
├─ strip-ansi@3.0.1
│  └─ ansi-regex@^2.0.0
├─ supports-color@2.0.0
├─ tar-pack@3.4.0
│  ├─ debug@^2.2.0
│  ├─ fstream-ignore@^1.0.5
│  ├─ fstream@^1.0.10
│  ├─ once@^1.3.3
│  ├─ readable-stream@^2.1.4
│  ├─ rimraf@^2.5.1
│  ├─ tar@^2.2.1
│  └─ uid-number@^0.0.6
├─ tar@2.2.1
│  ├─ block-stream@*
│  ├─ fstream@^1.0.2
│  └─ inherits@2
├─ tether@1.4.0
├─ throttle-debounce@1.0.1
├─ through2@0.6.5
│  ├─ readable-stream@>=1.0.33-1 <1.1.0-0
│  ├─ readable-stream@1.0.34
│  │  ├─ core-util-is@~1.0.0
│  │  ├─ inherits@~2.0.1
│  │  ├─ isarray@0.0.1
│  │  └─ string_decoder@~0.10.x
│  └─ xtend@>=4.0.0 <4.1.0-0
├─ tmp@0.0.31
│  └─ os-tmpdir@~1.0.1
├─ to-string-tag-x@1.1.0
│  ├─ lodash.isnull@^3.0.0
│  └─ validate.io-undefined@^1.0.3
├─ uid-number@0.0.6
├─ util-deprecate@1.0.2
├─ validate-npm-package-name@3.0.0
│  └─ builtins@^1.0.3
├─ validate.io-undefined@1.0.3
├─ vue@2.2.5
├─ which@1.2.14
│  └─ isexe@^2.0.0
├─ wrappy@1.0.2
├─ xtend@4.0.1
└─ yallist@2.1.2







原文地址:https://www.cnblogs.com/xiaoCong2016/p/6577101.html