-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
Open
Description
Version
v18.9.1
Platform
Darwin 1.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64
Subsystem
No response
What steps will reproduce the bug?
in https://github.com/kwasimensah/exports-not-loaded
- run
node test.js- fails with module not found error - Edit internal/foo/package.json to use "main" instead of "main_ignore"
node test.jsnow prints "Hello world"
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
requiring internal/foo should work without specifying main in the package.json per the legacy banner at https://nodejs.org/docs/latest/api/modules.html#folders-as-modules
What do you see instead?
rror: Cannot find module 'internal/foo'
Require stack:
- /Users/kwasimensah/Documents/GitHub/exports-not-loaded/test.js
at Module._resolveFilename (node:internal/modules/cjs/loader:955:15)
at Module._load (node:internal/modules/cjs/loader:803:27)
at Module.require (node:internal/modules/cjs/loader:1021:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/Users/kwasimensah/Documents/GitHub/exports-not-loaded/test.js:1:13)
at Module._compile (node:internal/modules/cjs/loader:1119:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/kwasimensah/Documents/GitHub/exports-not-loaded/test.js' ]
}
Additional information
The regex at
node/lib/internal/modules/cjs/loader.js
Line 538 in 73c0564
| const EXPORTS_PATTERN = /^((?:@[^/\\%]+\/)?[^./\\%][^/\\%]*)(\/.*)?$/; |
Metadata
Metadata
Assignees
Labels
No labels