modules: throw an error for invalid package.json main entries by BridgeAR · Pull Request #26823 · nodejs/node (original) (raw)
Thanks for changing the error.
The only other concern with this PR would be the chance of breaking scenarios - say if users are relying on the main not found causing a fallback in the in the main _findPath algorithm.
For example, consider the following folder structure
app/node_modules/pkg/package.json = { "main": "./does-not-exist" }
node_modules/pkg/package.json = { "main": "./does-exist.js" }
currently I think the lookup algorithm for require('pkg')
in app/
will actually load node_modules/pkg/does-exist.js
just fine (and this is just from scanning the code, do correct me if I'm wrong). So that is, there could well be working code that relies on this fallback.