Open
Description
Link to the code that reproduces this issue
To Reproduce
- Open the reproduction
- Observe
import.meta.dirname
isundefined
in the webpack-compiledpage.tsx
(but is a dir path in Node.js)
Changes to repro template:
- upgrade to Node.js 20.11.0 via dev container config
- switch to
"type": "module"
to enable running ESM with Node.js (and changemodule.exports =
toexport default
innext.config.js
) - add file
import-meta.dirname.js
withconsole.log()
ofimport.meta.dirname
- add
console.log()
ofimport.meta.dirname
toapp/page.tsx
Current vs. Expected behavior
I expected import.meta.dirname
and import.meta.filename
, introduced in Node.js 20.11.0 to not be undefined
in Next.js pages in the App Router, but it is undefined
Verify 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 PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Binaries:
Node: 20.11.0
npm: 10.2.4
Yarn: 1.22.19
pnpm: 8.14.1
Relevant Packages:
next: 14.1.1-canary.1
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 5.1.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Module resolution (CJS / ESM, module resolving)
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
No response