当前位置: 首页 > 编程笔记 >

yarn与npm的命令行小结

房泉
2023-03-14
本文向大家介绍yarn与npm的命令行小结,包括了yarn与npm的命令行小结的使用技巧和注意事项,需要的朋友参考一下

一、首先需要了解的命令

     npm install === yarn —— install 安装是默认行为。

     npm install taco --save === yarn add taco —— taco 包立即被保存到 package.json 中。

     npm uninstall taco --save === yarn remove taco

在 npm 中,可以使用 npm config set save true 设置 — -save 为默认行为,但这对多数开发者而言并非显而易见的。在 yarn 中,在package.json 中添加(add)和移除(remove)等行为是默认的。

     npm install taco --save-dev === yarn add taco --dev

     npm update --save === yarn upgrade

update(更新) vs upgrade(升级), 赞!upgrade 才是实际做的事!版本号提升时,发生的正是upgrade!

注意: npm update --save 在版本 3.11 中似乎有点问题。

     npm install taco@latest --save === yarn add taco

     npm install taco --global === yarn global add taco —— 一如既往,请谨慎使用 global 标记。

二、已知悉的命令

包和 npm registry 上是一样的。大致而言,Yarn 只是一个新的安装工具,npm 结构和 registry 还是一样的。

     npm init === yarn init

     npm link === yarn link

     npm outdated === yarn outdated

     npm publish === yarn publish

     npm run === yarn run

     npm cache clean === yarn cache clean

     npm login === yarn login (logout 同理)

     npm test === yarn test

三、Yarn 独有的命令

我跳过了一些提醒我们不要使用的内容,如 yarn clean。

     yarn licenses ls —— 允许你检查依赖的许可信息。

     yarn licenses generate —— 自动创建依赖免责声明 license。

     yarn why taco —— 检查为什么会安装 taco,详细列出依赖它的其他包(鸣谢 Olivier Combe)。

     Emojis

     速度

     通过 yarn lockfile 自动实现 shrinkwrap 功能

     以安全为中心的设计

四、Npm 独有的命令

     npm xmas === NO EQUIVALENT

     npm visnup === NO EQUIVALENT

总结

在写这篇文章的时候发现, yarn的run 命令似乎出了点问题,应该会在0.15.2中修复。在这一点上, npm 好多了。以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。

 类似资料:
  • NPM和Yarn命令对比 npm 命令 Yarn 命令 备注 npm install yarn install 安装依赖包 (N/A) yarn install —flat 单版本模式 (N/A) yarn install —har 生成har文件,记录安装时网络请求性能 (N/A) yarn install —no-lockfile 不读写lockfile方式 (N/A) yarn instal

  • 是否有npm或yarn命令来显示我的项目中安装了哪个版本的依赖项? 显示我的npm注册表中存在的版本。例如,我将设置为:但当我运行它向我显示 我知道我可以打开锁定文件,但很难处理。

  • =d:\users\pjha\appdata\roaming\npm\node_modules\tty.js\node_modules\ws (node-gyp rebuild 2>builderror.log)(退出0)d:\users\pjha\appdata\roaming\npm\node_modules\tty.js\node_modules\ws>如果未定义npm_config_nod

  • =D:\Users\pjha\AppData\Roaming\npm\node\u modules\tty。js\node\u模块\ws (节点gyp重建2

  • 我对gradle和npm都是新手,我正在尝试启动并运行一个Grails3-AngularJS2示例应用程序。 这是应用程序https://github.com/agileorbit/grails3-angular2-starter 当我尝试并运行该应用程序时,我得到以下异常,似乎发生在这里

  • 全局配置 你可以获得命令行帮助通过pyspider --help和pyspider all --help来获得帮助。 全局的选项适用于所有的子命令 ``` Usage: pyspider [OPTIONS] COMMAND [ARGS]... A powerful spider system in python. Options: -c, --config FILENAME