npm与yarn命令对比

Yarn是由Facebook、Google、Exponent 和 Tilde 联合推出了一个新的 JS 包管理工具 

Yarn 是为了弥补 npm 的一些缺陷而出现的(比如,npm install时候会很慢以及安全问题)

Yarn的优点:

1、速度快(并行安装和离线模)

2、安装版本统一

3、输出更简洁

4、语义化更好

npm5.0也较之前做出了调整

比如:

1、默认新增了类似yarn.lock的 package-lock.json

2、git 依赖支持优化

3、文件依赖优化

yarn和npm一些命令对比:

初始化项目

npm init
yarn init

默认安装依赖

npm install/link
yarn install/link
/*
npm install 命令会根据 package.json 安装依赖以及允许你添加新的模块
yarn install 仅会按 yarn.lock 或 package.json 里面的依赖顺序来安装模块
*/

安装某个依赖,并且默认保存到package

npm install taco —save
yarn add taco

移除某个依赖项目

npm uninstall taco —save
yarn remove taco

更新某个依赖项目

npm update taco —save
yarn upgrade taco

运行某个命令

npm run/app
yarn run/app

参考文档:

http://web.jobbole.com/88459/

猜你喜欢

转载自www.cnblogs.com/theblogs/p/10383513.html