过去一般软件包管理器用npm,现在用更高级的yarn;
Yarn的优点:
速度快
并行安装
离线模式
安装版本统一
更简洁的输出
Yarn和npm命令对比
npm | yarn |
---|---|
npm install | yarn |
npm install react --save | yarn add react |
npm uninstall react --save | yarn remove react |
npm install react --save-dev | yarn add react --dev |
npm update --save | yarn upgrade |
1、查看版本
1 2 |
|
2、安装淘宝镜像
yarn config set registry 'https://registry.npm.taobao.org' npm install -g cnpm --registry=http://registry.npm.taobao.org
3、初始化某个项目
yarn init npm init
4、默认安装项目依赖
yarn install cnpm install
5、安装某个依赖,并且默认保存到package
1 2 |
|
6、卸载某个项目依赖
yarn remove xxx cnpm uninstall xxx --save
7、更新某个项目依赖
1 2 |
|
8、安装某个全局的项目依赖
yarn global add xxx cnpm install xxx -g
9、安装某个特定版本号的项目依赖
yarn add xxx@ cnpm install xxx@1.2.33 --save
10、发布/登录/登出,一系列NPM Registry操作
yarn publish/login/logout npm publish/login/logout
11、运行某个命令
1 2 |
|