在package.json的devdependencies中包含npm可以吗? [英] Is it okay to include npm in devdependencies in package.json?

查看:125
本文介绍了在package.json的devdependencies中包含npm可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个nodejs存储库,该存储库在开发依赖项中包含npm.在什么情况下需要这样的配置?因为,安装依赖关系已经需要npm.

I came across a nodejs repo that included npm in devdependencies. What would be the case that requires such config? Because, installing devdependencies already requires npm.

推荐答案

如果存储库内部使用NPM CLI并依赖于特定的NPM版本而不是全局安装的NPM,则这很有意义,因为在主要版本之间可能会更改行为:

This makes sense if a repository uses NPM CLI internally and relies on specific NPM version instead of globally installed NPM, because the behaviour may be changed between major releases:

devDependencies: {
  "npm": "^2"
}

devDependencies: {
  "npm": "*"
}

没什么意义,只是它可能会使用最新的稳定NPM版本,尽管该版本已在本地系统上全局安装.

won't make much sense, except that it will likely use latest stable NPM version, despite which version was installed globally on local system.

如果使用NPM 以编程方式,这也很有意义.因为全局软件包通常不能require d.

This also makes sense if NPM is used programmatically because global packages cannot be normally required.

这篇关于在package.json的devdependencies中包含npm可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆