attempting to use import.meta.resolve results in an error
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/souporserious/next-import-meta-resolve-bug
To Reproduce
Attempt to use import.meta.resolve('./any-path') in a Server or Client Component
Current vs. Expected behavior
import.meta.resolve('./any-path') should work as expected with Node.js 20.8.0 and above, currently this error is thrown when attempting to use it:
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.2.0: Fri Dec 6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000
Available memory (MB): 16384
Available CPU cores: 10
Binaries:
Node: 21.2.0
npm: 10.8.1
Yarn: 1.22.21
pnpm: 9.9.0
Relevant Packages:
next: 15.1.6 // Latest available version is detected (15.1.6).
eslint-config-next: N/A
react: 19.0.0
react-dom: 19.0.0
typescript: 5.7.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Webpack, Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction repository and reproduce the failure in next dev and next build using Node.js 20.8.0 or newer. Compare the behavior in the Webpack and Turbopack stages for import.meta.resolve('./any-path') in Server and Client Components. Done means the call works as expected in both affected stages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js, node.js, react, webpack
- Domain
- build-system, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100