Repository navigation
Closed
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.Confirmed issue that is tracked by the Next.js team.locked
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64
Binaries:
Node: 18.12.0
npm: 8.19.2
Yarn: 3.2.4
pnpm: N/A
Relevant packages:
next: 13.0.2-canary.2
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
When using Yarn PnP to manage packages, running next bulid with appDir enabled will fail to build.
The build log is:
warn - You have enabled experimental feature (appDir) in next.config.js.
warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback
warn - `enableUndici` option is unnecessary in Node.js v18.0.0 or greater.
> Build error occurred
Error: EROFS: read-only filesystem, open '/node_modules/next/dist/server/initialize-require-hook.js'
at makeError$1 (/Users/shun_shobon/tmp/my-app/.pnp.cjs:958:24)
at EROFS (/Users/shun_shobon/tmp/my-app/.pnp.cjs:985:10)
at ZipFS.prepareWriteFile (/Users/shun_shobon/tmp/my-app/.pnp.cjs:2820:13)
at ZipFS.writeFilePromise (/Users/shun_shobon/tmp/my-app/.pnp.cjs:2791:55)
at /Users/shun_shobon/tmp/my-app/.pnp.cjs:3912:26
at /Users/shun_shobon/tmp/my-app/.pnp.cjs:4136:81
at ZipOpenFS.getZipPromise (/Users/shun_shobon/tmp/my-app/.pnp.cjs:4243:22)
at ZipOpenFS.makeCallPromise (/Users/shun_shobon/tmp/my-app/.pnp.cjs:4136:23)
at ZipOpenFS.writeFilePromise (/Users/shun_shobon/tmp/my-app/.pnp.cjs:3909:23)
at VirtualFS.writeFilePromise (/Users/shun_shobon/tmp/my-app/.pnp.cjs:3219:24) {
code: 'EROFS'
}
Looking at the error log, it appears that the attempt to write in next/dist/server/initialize-require-hook.js is failing:
next.js/packages/next/build/index.ts
Lines 317 to 324 in ef73798
| await promises | |
| .writeFile( | |
| initialRequireHookFilePath, | |
| content.replace( | |
| /isPrebundled = (true|false)/, | |
| `isPrebundled = ${isAppDirEnabled}` | |
| ) | |
| ) |
Expected Behavior
No error logs are displayed and the build succeeds.
Link to reproduction
https://github.com/shun-shobon/nextjs-13-yarn-berry-build-reproduction
To Reproduce
- clone this repo
- run
yarnto install dependencies - run
yarn build - an error log is output and the build fails
Reacted by Sebastian Eßfeld, Travis DePrato, Rintaro Itokawa, Sumin Lee, Taylor Blanton, Alfred, subaru, 陈杨文, 유민호(Minho), guilherme rosa and 23 more
Metadata
Metadata
Assignees
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.Confirmed issue that is tracked by the Next.js team.locked
Activity
twavv commentedon Nov 3, 2022
I just ran into this. A temporary workaround is to
yarn unplug next.nastynaz commentedon Dec 11, 2022
I spent hours trying to figure this out. Bump.
Revolt9k commentedon Dec 13, 2022
Same problem
madjam002 commentedon Dec 16, 2022
This is also a problem when running ‘next build’ where node_modules is on a read only file system as is the case with some build systems.
cyrilwanner commentedon Jan 16, 2023
We are also facing this issue with Bazel (rules_js & pnpm) when trying to enable the appDir feature.
Modifying files within node_modules might work for simple setups, but can cause a lot of issues with more complex and restrictive build systems where node_modules is on a read only file system (for example to avoid any side effects when sharing dependencies between build agents and for guaranteeing hermetic builds).
It looks like this was introduced in #41687
@huozhi @ijjk would it be possible to maybe move this file to the
.nextoutput folder or avoid writing it in node_modules in another way, e.g. by checking if the appDir feature is enabled differently?I am also happy to contribute if there is a common agreement on how this should be fixed.
samwightt commentedon Jan 18, 2023
Bump, this really needs attention. Huge blocker for anyone using yarn 2.
ranisalt commentedon Feb 18, 2023
Not a good idea for a dependency to modify its own source code when ran... Just generate this file elsewhere
power-f-GOD commentedon Mar 8, 2023
I just faced this issue with
pnpmas well.😕 Any concrete solutions yet?codebycarlos commentedon Mar 9, 2023
Just came across this as well, huge problem for anyone using Yarn's PnP.
unplug next until appDir and yarn pnp play nicely together vercel/nex…
faeb187 commentedon Mar 22, 2023
yarn 3.4.1 @samwightt not only v2 affected.
node LTS 18.14.1
next@latest same as with next@v13.2.5-canary.12 (obviously, PNP both default)
Workaround (opt-out Yarn PNP and use node_modules again):
Output:
➤ YN0000: Successfully set nodeLinker to 'node-modules'Now
yarn buildworks again (or you messed up on your own ^^)bryanjtc commentedon Apr 16, 2023
Trying to use the workaround by unplugging next in a project using module and module resolution node 16 throws this error. My project has type module in the package.json
oxc commentedon Apr 30, 2023
@bryanjtc, this is unrelated to Yarn PnP. I've reported this issue with some background and a workaround (enable
typedRoutesexperimental feature) in #49004yannbolliger commentedon May 11, 2023
Looks like this fixed for us (with @cyrilwanner) Bazel with rules_js & pnpm, from
next@13.4.1. 👍huozhi commentedon Jul 24, 2023
Tested the reproduction attached in the description with latest nextjs, it works well for me, will close this issue now.
kgsvg commentedon Jul 28, 2023
The issue for me was
getInitialProps. I had done it likeHome.getInitialProps = async () => {}but it should be exported on the module level like so:github-actions commentedon Aug 15, 2023
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.