Yarn 的简介:
Yarn是facebook发布的一款取代npm的包管理工具;
Yarn的特点:
1)速度超快----Yarn缓存了每个下载过的包,所以再次使用时无需重复下载。同时利用并行下载以最大化资源利用率,因此安装快。
2)超级安全----在执行代码之前,Yarn会通过算法检验每个安装包的完整性。
3)超级可靠-----使用详细、简洁的锁文件格式和明确的安装算法,Yarn能够保证在不同系统上无差异工作。
Yarn的安装:
1、下载nodejs,使用npm安装
npm install -g yarn
查看版本 :
yarn --version
2、Yarn配置淘宝源,分别复制黏贴以下代码运行即可;
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
npm 与 yarn 命令比较:
NPM | YARN | 说明 |
---|---|---|
npm init | yarn init | 初始化某个项目 |
npm install / link | yarn install/link | 默认的安装依赖操作 |
npm install taco --save | yarn add taco | 安装某个依赖,并且默认保存到package |
npm uninstall taco --save | yarn remove taco | 移除某个依赖项目 |
npm install taco --save-dev | yarn add taco --dev | 安装某个开发时依赖项目 |
npm update taco --save | yarn upgrade taco | 更新某个依赖项目 |
npm install taco --global | yarn global add taco | 安装某个全局依赖项目 |
npm publish/login/logout | yarn publish/login/logout | 发布/登录/登出,一系列NPM Registry操作 |
npm run/test | yarn run/test | 运行某个命令 |