Open dudulaopo833 opened 7 years ago
https://yarnpkg.com/zh-Hans/docs/cli https://segmentfault.com/a/1190000007189426
如果原先有npm工具的话,安装yarn很简单,只需要一行命令即可 npm install -g yarn 如果没有npm工具,安装yarn可参照各平台下yarn工具安装方式
yarn config list 安装yarn之后默认的包安装源是https://registry.yarnpkg.com,可用查看命令 yarn config get registry 若想提高yarn安装的速度,可将包安装源修改为cnpm的安装源,执行以下命令即可 yarn config set registry 'https://registry.npm.taobao.org'
初始化某个项目
npm init yarn init
默认的安装依赖操作
npm install/link yarn install/link
安装某个开发时依赖项目
npm install --save-dev xxx yarn add xxx --dev
移除某个依赖项目
npm uninstall --save-dev xxx yarn remove xxx
更新某个依赖项目
npm update --save-dev xxx yarn upgrade xxx
安装某个全局依赖项目
npm install -g xxx yarn global add xxx
发布/登录/登出,一系列NPM Registry操作
npm publish/login/logout yarn publish/login/logout
运行某个命令
npm run/test -> yarn run/test
缓存
yarn cache --> 查看缓存 yarn cache clear --> 清理缓存
查看远程包的信息
yarn info xxx
12.查看安装包
yarn list
自我更新
yarn self-update
查找原因
yarn why xxx
运行script
npm run xxx -> yarn run xxx
连接其他包,或者本地发布
npm link -> yarn link npm unlink -> yarn unlink
发布包
yarn login -> yarn publish xxxx(folder name) --> yarn logout
Useful Link:
https://yarnpkg.com/zh-Hans/docs/cli https://segmentfault.com/a/1190000007189426
Yarn 是facebook推出的优化了npm的替代工具,会缓存以前下载的包, 速度会快很多;且安装命令也简洁些
安装
如果原先有npm工具的话,安装yarn很简单,只需要一行命令即可 npm install -g yarn 如果没有npm工具,安装yarn可参照各平台下yarn工具安装方式
配置
使用
初始化某个项目
默认的安装依赖操作
安装某个开发时依赖项目
移除某个依赖项目
更新某个依赖项目
安装某个全局依赖项目
发布/登录/登出,一系列NPM Registry操作
运行某个命令
缓存
查看远程包的信息
12.查看安装包
自我更新
查找原因
运行script
连接其他包,或者本地发布
发布包