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

CJS module not loading with import #38976

Closed
perrin4869 opened this issue Jun 9, 2021 · 1 comment
Closed

CJS module not loading with import #38976

perrin4869 opened this issue Jun 9, 2021 · 1 comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs.

Comments

@perrin4869
Copy link

  • Version: v16.3.0
  • Platform: Linux landau.julian.dotcore.co.il 5.4.60 deps: update openssl to 1.0.1j #1 SMP Fri Aug 21 14:39:48 CDT 2020 x86_64 Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz GenuineIntel GNU/Linux
  • Subsystem: esm

What steps will reproduce the bug?

The following minimal project will do:

❯ cat package.json
{
  "type": "module",
  "devDependencies": {
    "cross-fetch": "^3.1.4"
  }
}
❯ cat index.js
import "cross-fetch/polyfill";
❯ node --experimental-specifier-resolution=node index.js
node:internal/process/esm_loader:74
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/perrin4869/univapay/cross-fetch-esm/node_modules/cross-fetch/polyfill' imported from /home/perrin4869/univapay/cross-fetch-esm/index.js
Did you mean to import cross-fetch-esm/node_modules/cross-fetch/dist/node-polyfill.js?
    at new NodeError (node:internal/errors:363:5)
    at finalizeResolution (node:internal/modules/esm/resolve:296:11)
    at moduleResolve (node:internal/modules/esm/resolve:742:10)
    at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:853:11)
    at Loader.resolve (node:internal/modules/esm/loader:89:40)
    at Loader.getModuleJob (node:internal/modules/esm/loader:242:28)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:73:40)
    at link (node:internal/modules/esm/module_job:72:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

What is the expected behavior?

Since the module cross-fetch/polyfill loads flawlessly over cjs, and I understand that most cjs modules should load under esm as a default export, I expected the module to load without this error.

What do you see instead?

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/perrin4869/univapay/cross-fetch-esm/node_modules/cross-fetch/polyfill' imported from /home/perrin4869/univapay/cross-fetch-esm/index.js

Additional information

Related: lquixada/cross-fetch#110

@aduh95
Copy link
Contributor

aduh95 commented Jun 9, 2021

Duplicate of #38739.

@aduh95 aduh95 closed this as completed Jun 9, 2021
@aduh95 aduh95 added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs.
Projects
None yet
Development

No branches or pull requests

2 participants