-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Labels
TurbopackRelated to Turbopack with Next.js.Related to Turbopack with Next.js.
Description
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/angry-lalande-98zyn5
To Reproduce
require()a cjs module, for example ingetServerSidePropsor in a server component. Import location does not matter.- Inside of the module, try to access
__dirname- it is/ROOT/...instead of the real path.import.meta.urlworks correctly though - this is not a valid workaround though, since this normally does not work in CommonJS.
Current vs. Expected behavior
__dirname should work the same as when using Webpack / be consistent with data reported from import.meta
Provide environment information
Node: 20.12.1
npm: 10.5.0
Yarn: 1.22.19
pnpm: 8.15.6
Relevant Packages:
next: 16.0.2-canary.34 // Latest available version is detected (16.0.2-canary.34).
eslint-config-next: N/A
react: 19.2.0
react-dom: 19.2.0
typescript: 5.9.3
Next.js Config:
output: N/AWhich area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
No response
Metadata
Metadata
Assignees
Labels
TurbopackRelated to Turbopack with Next.js.Related to Turbopack with Next.js.