之前个人所接触的Vue项目,大多时候的JavaScript包管理工具都是用npm,自从用了Yarn以后,就果断放弃Npm了,为什么呢?因为Yarn本身其实也是在npm的基础上进行改进的,弥补了Npm速度慢,安全等方面的不足。
Yarn比Npm的优势
1)加入了缓存机制,离线安装,速度比Npm更快;
2)加入算法校验包完整性,更安全(npm安装时可以运行代码,不安全);
3)使用详细、简洁的锁文件格式和明确的安装算法,Yarn 能够保证在不同系统上无差异的工作,更可靠。
Yarn命令 | Npm命令 | 说明 | 备注 |
yarn install | npm install | 安装模块 | |
yarn uninstall | npm uninstall | 卸载模块 | |
yarn update | npm update | 更新模块 | |
yarn outdated | npm outdated | 检查模块是否已经过时 | |
yarn ls | npm ls | 查看安装的模块 | |
yarn init | npm init | 在项目中引导创建一个package.json文件 | |
yarn help | npm help | 查看某条命令的详细帮助 | |
yarn root | npm root | 查看包的安装路径 | |
yarn config | npm config | 管理配置路径 | |
yarn cache | npm cache | 管理模块的缓存 | |
yarn start | npm start | 启动模块 | |
yarn stop | npm stop | 停止模块 | |
yarn restart | npm restart | 重新启动模块 | |
npm test | 测试模块 | ||
npm version | 查看模块版本 | ||
npm view | 查看模块的注册信息 | ||
npm adduser | 用户登录 | ||
npm publish | 发布模块 | ||
npm access | 在发布的包上设置访问级别 | ||
yarn add <package> | npm install <package> --save | 添加包依赖使用 |
后面继续补充