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 use in ESM project (Node 20) #42

Closed
andrewmackrodt opened this issue Dec 8, 2023 · 1 comment
Closed

Unable to use in ESM project (Node 20) #42

andrewmackrodt opened this issue Dec 8, 2023 · 1 comment

Comments

@andrewmackrodt
Copy link

This appears to be the same as #37; I am receiving the error:

import { registerInterceptor } from 'axios-cached-dns-resolve';
         ^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'registerInterceptor' not found. The requested module 'axios-cached-dns-resolve' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'axios-cached-dns-resolve';
const { registerInterceptor } = pkg;

However, that advice does not work as this isn't a CJS module. Manually editing the package.json of axios-cached-dns-resolve to include "type": "module" fixes the issue.

@andrewmackrodt
Copy link
Author

Closing after reading #9 and re-reading "ECMAScript module (esm), not native esm/.mjs with package.json type: module, requires esm" in README.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant