-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed
Labels
moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.
Description
Currently, it is impossible to write code like:
let Bluebird;
try {
Bluebird = require('bluebird');
} catch (e) {
execSync('npm install bluebird');
Bluebird = require('bluebird');
} Because the cjs loader caches the results of stat calls internally so it would not look for bluebird the second time we require it.
It would be pretty easy to deal with this use case from a technical point of view by setting statCache to a new Map() on a MODULE_NOT_FOUND.
I can see several use cases like:
- Writing repls in userland
- Writing a "lazy loading" require hook that recovers from 'module not found' errors by npm install`
Would people be in favor of this change and enabling this?
cc @nodejs/modules
cc @BridgeAR because of #26928 that enables this specifically for the REPL.
LMojicaDavidWeiss2
Metadata
Metadata
Assignees
Labels
moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.