-
Notifications
You must be signed in to change notification settings - Fork 355
Open
Labels
Description
You all are using the _requiredBy field in installed modules:
This concerns me because the contents of keys beginning with _ are not a part of npm's semver contract, so we can and will change these in the future. Further, it's not the sort of thing we even call out in changelogs as it's entirely internal to npm.
I'd love to work with you all to find a solution that can be a part of our semver contract and is thus more supportable. To do that I would find it helpful if you all could help me understand what questions you're looking for answers to about modules. From the code linked to, it looks like the question is just "is this a top level dependency?" – is that correct?
As you are using this, you should be aware of some further caveats:
- This is essentially a write-only field for npm. It uses this to store what it was thinking at install time, but it recomputes these after reading them off disk. This means none of npm's logic actually depends what's in the file.
- If an installed module was bundled and you installed it with npm < 3.5.0, its
package.jsonwon't have any of this metadata in it. npm prior to 3.5.0 didn't rewrite bundle module'spackage.jsonfiles at all. Similarly, if any of the modules were originally installed with npm less than 3, then they won't have this metadata. - It is made up of either
#USER(which means the user installed it but didn't save it to theirnode_modulesfolder),#EXISTING(which means we found it here and it previously didn't have a_requiredBykey, typically folders w/ npm@2 modules), a module-centric path to a thing that requires it (eg/moduleA/moduleB), or#DEV:followed by a module-centric path to a thing that requires it (eg#DEV:/moduleC/moduleD).#DEV:type entries are (unsurprisingly) created when the module is required by a development dependency.