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

Error: Must use import to load ES Module #1956

Closed
pberlinets opened this issue Dec 30, 2021 · 1 comment
Closed

Error: Must use import to load ES Module #1956

pberlinets opened this issue Dec 30, 2021 · 1 comment

Comments

@pberlinets
Copy link

After update GOT library to version 12.0.0 I've got an error:

Error:  Must use import to load ES Module: .../node_modules/got/dist/source/index.js
require() of ES modules is not supported.
require() of .../node_modules/got/dist/source/index.js from .../CompaniesPage.ts is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from .../node_modules/got/package.json.
  • Node.js version: v14.18.2
  • OS & version: MacOS Monterey 12.0.1 (21A559)

Actually, I'm using proper import and don't realize where the problem is

import got from "got";
@sindresorhus
Copy link
Owner

Please read the release notes. Issues like these are usually caused by your build tool incorrectly transpiling dependencies like Got to CommonJS.

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

Repository owner locked as resolved and limited conversation to collaborators Dec 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants