What is `“dev” true` in package-lock.json for?

被刻印的时光 ゝ 提交于 2019-12-04 22:34:32
Kyle Reynolds

From the npm docs at https://docs.npmjs.com/files/package-lock.json

If true then this dependency is either a development dependency ONLY of the top level module or a transitive dependency of one. This is false for dependencies that are both a development dependency of the top level and a transitive dependency of a non-development dependency of the top level.

I think this paragraph tries to illustrate how the package dependency's dev: true is assigned.

  • Directly development dependency -> dev: true
  • With only indirect development dependency -> dev: true
  • Directly development dependency however it also has indirect non-develop dependency -> no "dev: true"

In other words, once a develop dependency package is indirectly dependent by a non-development package, it shall be dev: false and thus it will be included in the build process. The purpose of this rule is to make sure that packages needed by the non-develop package will not have "dev: true".

Besides, if install via "npm install -D , then the package will be installed as the develop package thus no "dev: true" changes may occur. However, if install via "npm install ", this may remove many existing dependencies' "dev: true" attribute.

For example, I run "npm install -D bestzip" in my project and the ressult is:

  • 53 dependencies with "dev": true added

Run "npm install bestzip" and the result is:

  • 53 dependencies without "dev": true added
  • 43 existing dependencies' "dev": true attribute are removed
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!