当前位置: 首页 > 文档资料 > Yarn 学习笔记 >

Yarn 命令 vs NPM 命令

优质
小牛编辑
132浏览
2023-12-01

NPM和Yarn命令对比

npm 命令Yarn 命令备注
npm installyarn install安装依赖包
(N/A)yarn install —flat单版本模式
(N/A)yarn install —har生成har文件,记录安装时网络请求性能
(N/A)yarn install —no-lockfile不读写lockfile方式
(N/A)yarn install —pure-lockfile不生成yarn.lock文件
npm install [package](N/A)安装依赖
npm install —save [package]yarn add [package]添加生产模式依赖到项目
npm install —save-dev [package]yarn add [package] [—dev/-D]添加开发模式的依赖
(N/A)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]
(N/A)yarn add [package] [—tilde/-T]
npm install —global [package]yarn global add [package]
npm rebuildyarn install —force
npm uninstall [package](N/A)
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 cleanyarn cache clean
rm -rf node_modules && npm installyarn upgrade-