dependency与devDependencies的区别是什么?

引入 npm 官网对 dependency 与 devDependencies 的官方解释:

  • “dependency”:These packages are required by your application in production.(这些软件包是生产中的应用程序需要的)
  • “devDependencies”: These packages are only needed for development and testing.(这些包仅用于开发和测试)

简而言之,就是打包上线的就下载到 dependency 中

如何下载安装的包

  • “dependency”: npm i --save <package>
  • “devDependencies”:npm i --save-dev <package>

更新本地安装的包

  1. 在 package.json 文件所在的目录中执行 npm update 命令。
  2. 执行 npm outdated 命令。不应该有任何输出。

卸载本地安装的包

  1. npm uninstall <package>
  2. 如需从 package.json 文件中删除依赖,需要在命令后添加参数 --save : npm uninstall --save <package>
  3. 如果你将安装的包作为"devDependency",必须通过 --save-dev : npm uninstall --save-dev <package>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
yarn add opencv-js yarn add v1.22.19 warning package.json: "dependencies" has dependency "css-loader" with range "^0.28.1" that collides with a dependency in "devDependencies" of the same name with version "^0.28.0" warning package.json: "dependencies" has dependency "webpack" with range "^2.5.0" that collides with a dependency in "devDependencies" of the same name with version "^2.2.1" warning package.json: "dependencies" has dependency "webpack-dev-server" with range "^2.4.5" that collides with a dependency in "devDependencies" of the same name with version "^2.3.0" warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. warning [email protected]: "dependencies" has dependency "css-loader" with range "^0.28.1" that collides with a dependency in "devDependencies" of the same name with version "^0.28.0" warning [email protected]: "dependencies" has dependency "webpack" with range "^2.5.0" that collides with a dependency in "devDependencies" of the same name with version "^2.2.1" warning [email protected]: "dependencies" has dependency "webpack-dev-server" with range "^2.4.5" that collides with a dependency in "devDependencies" of the same name with version "^2.3.0" [1/4] Resolving packages... warning dragact > jest > jest-cli > jest-haste-map > sane > [email protected]: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2 warning webpack > watchpack > watchpack-chokidar2 > chokidar > [email protected]: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2 warning @kadira/storybook > webpack > watchpack > chokidar > [email protected]: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2 error Received malformed response from registry for "opencv-js". The registry may be down. info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command
06-09

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值