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

attempting to use import.meta.resolve results in an error #75292

Open
souporserious opened this issue Jan 24, 2025 · 1 comment
Open

attempting to use import.meta.resolve results in an error #75292

souporserious opened this issue Jan 24, 2025 · 1 comment
Labels
Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js.

Comments

@souporserious
Copy link
Contributor

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:

Image

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

@github-actions github-actions bot added Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js. labels Jan 24, 2025
@souporserious
Copy link
Contributor Author

Side note, I think import.meta.resolve should work like import.meta.url and actually point to the file system instead of what require.resolve does right now which ends up with a path like (rsc)/../../.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant