Must use import to load ES Module (using ky/ky-universal library) #21253
Unanswered
matveychuk
asked this question in
Help
Replies: 3 comments 1 reply
-
Also experiencing the same issue |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes, I have same problem with ky/ky-universal packages. |
Beta Was this translation helpful? Give feedback.
1 reply
-
This is a Next.js side problem. In the meantime, we can use Related: sindresorhus/ky#336 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What version of Next.js are you using?
10.0.5
What version of Node.js are you using?
14.15.4
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
localhost
Describe the Bug
When trying to use ky/ky-universal with the newly created Next.js app receive such error:
Error: Must use import to load ES Module: /Users/---/node_modules/ky-universal/index.js
require() of ES modules is not supported.
require() of /---/node_modules/ky-universal/index.js from /---/.next/server/pages/index.js 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 /---/node_modules/ky-universal/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /---/node_modules/ky-universal/package.json.
Packages version:
Node 14.15.4,
"dependencies": {
"ky": "^0.26.0",
"ky-universal": "^0.9.1",
"next": "10.0.5",
"react": "17.0.1",
"react-dom": "17.0.1"
}
Code extract
Maintainers of ky state that "This package(ky/ky-universal) is correctly set up for ESM, so Next.js is doing something wrong."
Expected Behavior
Possibility to fetch data with ky library
To Reproduce
Create new Next.js app, add ky and ky-universal and try to do any HTTP request.
Beta Was this translation helpful? Give feedback.
All reactions