https://yarnpkg.com/en/docs/cli/
yarn init #初始化package.json – 和npm一致
#添加依赖
yarn add [package] — 添加包,会自动安装最新版本,注意会覆盖指定版本号!!!
yarn add [package]@[version] — 带版本号安装
yarn add [package]@[tag] — tag,是指代git上的推送的tag【no release!!】,看图
yarn upgarde, 会遍历所有依赖,然后全部更新
yarn remove [package] — 移除某个包
yarn管理器支持两种安装所有依赖的命令:yarn 或者 yarn install
命令比较
npm | Yarn |
---|---|
npm install |
yarn install |
(不适用) | yarn install --flat |
(不适用) | yarn install --har |
(不适用) | yarn install --no-lockfile |
(不适用) | yarn install --pure-lockfile |
npm install [package] |
(不适用) |
npm install --save [package] |
yarn add [package] |
npm install --save-dev [package] |
yarn add [package] [--dev/-D] |
(不适用) | yarn add [package] [--peer/-P] |
npm install --save-optional [package] |
yarn add [package] [--optional/-O] |
npm install --save-exact [package] |
yarn add [package] [--exact/-E] |
(不适用) | yarn add [package] [--tilde/-T] |
npm install --global [package] |
yarn global add [package] |
npm update --global |
yarn global upgrade |
npm rebuild |
yarn install --force |
npm uninstall [package] |
(不适用) |
npm uninstall --save [package] |
yarn remove [package] |
npm uninstall --save-dev [package] |
yarn remove [package] |
npm uninstall --save-optional [package] |
yarn remove [package] |
npm cache clean |
yarn cache clean |
rm -rf node_modules && npm install |
yarn upgrade |
Comments