Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import in REPL #35

Closed
Richienb opened this issue Nov 20, 2024 · 1 comment
Closed

Unable to import in REPL #35

Richienb opened this issue Nov 20, 2024 · 1 comment

Comments

@Richienb
Copy link

Richienb commented Nov 20, 2024

Node.js REPL:

Welcome to Node.js v20.15.1.
Type ".help" for more information.
> require('node-stdlib-browser')
Uncaught Error: Cannot find module './mock/empty.js'
Require stack:
- <repl>
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Function.resolve (node:internal/modules/helpers:190:19)
    at resolvePath (C:\Users\richi\Documents\GitHub\node-polyfill-webpack-plugin\node_modules\node-stdlib-browser\cjs\index.js:37:333) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '<repl>' ]
}
> await import('node-stdlib-browser')
Uncaught Error: Cannot find module './mock/empty.js'
Require stack:
- <repl>
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Function.resolve (node:internal/modules/helpers:190:19)
    at resolvePath (file:///C:/Users/richi/Documents/GitHub/node-polyfill-webpack-plugin/node_modules/node-stdlib-browser/esm/index.js:30:133)
    at file:///C:/Users/richi/Documents/GitHub/node-polyfill-webpack-plugin/node_modules/node-stdlib-browser/esm/index.js:40:23
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:432:15)
    at async REPL2:1:33 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '<repl>' ]
}

./mock/empty.js does exist though, maybe the relative resolution system broke somehow.

Able to import from a regular file though.

@Richienb Richienb changed the title Unable to import Unable to import in REPL Nov 20, 2024
@niksy
Copy link
Owner

niksy commented Nov 20, 2024

It seems like issue is here: https://github.com/niksy/node-stdlib-browser/blob/master/index.js#L9

Adding initial check for require before globalThis.require seemingly uses different globally available method. I thought these are the same methods but this doesn’t seem to be the case.

There’s even module check script for checking CJS and ESM format which passes every time, but this really seems like weird edge case.

@niksy niksy closed this as completed in 26208c0 Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants