Module not found: ESM packages (/path/to/app/page.js) need to be imported.
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Tue Sep 13 07:51:46 UTC 2022
Binaries:
Node: 18.12.0
npm: 8.19.2
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.0.0
eslint-config-next: 12.3.1
react: 18.2.0
react-dom: 18.2.0
warn - Latest canary version not detected, detected: “13.0.0”, newest: “12.3.2-canary.43”.
Please try the latest canary version (npm install next@canary
) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
Here is the error output when I run npm run dev
or build
:
Module not found: ESM packages (/path/to/app/page.js) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals
https://nextjs.org/docs/messages/module-not-found
Could someone give me direction since I don’t know where to start with this bug?
I have enabled the novel app
directory (experimental: { appDir: true }
) and tried to put page.js
and layout.js
files in it.
Expected Behavior
Load page.js
and layout.js
properly.
Link to reproduction
To Reproduce
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Import ES module in Next.js ERR_REQUIRE_ESM
I got it working by dynamically importing ky before using it but it's not elegant nor efficient. const handleFormSubmit = async (event) =>...
Read more >module-not-found - Next.js
When importing a module from npm this module has to be installed locally. For example when importing the swr package: import useSWR from...
Read more >Modules: Packages | Node.js v19.3.0 Documentation
It can load JSON modules, but an import assertion is required. ... If a package.json file does not have a "type" field, .js...
Read more >esm - npm
esm. 3.2.25 • Public • Published 4 years ago ... esm is the world's most advanced ECMAScript module loader. This fast, production ready, ......
Read more >Using ECMAScript modules (ESM) with Node.js
CommonJS modules, though ubiquitous thanks to Node.js, are not ... along with Node: CommonJS is already a module system, and ESM has to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@vladshcherbin Thanks for confirmation, I’ll close this issue as resolved.
@schickling it’s related to the esm package resolving, it’s caused by a different issue. will track yours in https://github.com/vercel/next.js/issues/42534 as duplicate issue
Using
*.jsx
as file extension also resolves the problem.