You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041
Available memory (MB): 24576
Available CPU cores: 12
Binaries:
Node: 22.13.1
npm: 10.9.2
Yarn: N/A
pnpm: 10.6.1
Relevant Packages:
next: 15.2.3 // Latest available version is detected (15.2.3).
eslint-config-next: N/A
react: 19.0.0
react-dom: 19.0.0
typescript: 5.8.2
Next.js Config:
output: standalone
Which area(s) are affected? (Select all that apply)
Output
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
Upon further inspection I noticed that afterpnpm install and beforepnpm build (next build), the projects/ui/node_modules doesn't have .pnpm folder. The projects/ui/node_modules as expected contains symlinks to the root node_modules/.pnpm with next, react and react-dom packages.
However, after I run next build the contents of projects/ui/node_modules is modified and the .pnpm folder appears with:
Hello! This seems to be a #48017 replica.
In a nutshel, pnpm centralized storage with synlinks does not woks really well with Next standalone applications.
A workaround is configuring your .npmrc to force the traditional approach (used by npm and yarn) when installing dependencies. node-linker=hoisted
@HenriqueSenaDev
I've seen that issue, however the node-linker=hoisted doesn't seem to have an effect on next build
Indeed, the node_modules directory becomes yarn-like flat and pnpm doesn't even create projects/ui/node_modules, but next build still creates a projects/ui/node_modules by itself with truncated next and styled-jsx packages.
This leads to Error: Cannot find module '../../lib/get-network-host' nevertheless (just tried it again with my repro)
Link to the code that reproduces this issue
https://github.com/eddienubes/next-pnpm-standalone-bug-repro/tree/main
To Reproduce
Preliminary actions
Standard monorepo setup, where one of the projects is next.js.
Error:
Error: Cannot find module '../../lib/get-network-host'
Current vs. Expected behavior
ER:
Standalone server successfully launches
AR:
Server.js inside standalone folder fails to locate a module ../../lib/get-network-host
with error:
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041 Available memory (MB): 24576 Available CPU cores: 12 Binaries: Node: 22.13.1 npm: 10.9.2 Yarn: N/A pnpm: 10.6.1 Relevant Packages: next: 15.2.3 // Latest available version is detected (15.2.3). eslint-config-next: N/A react: 19.0.0 react-dom: 19.0.0 typescript: 5.8.2 Next.js Config: output: standalone
Which area(s) are affected? (Select all that apply)
Output
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
Upon further inspection I noticed that after
pnpm install
and beforepnpm build
(next build), theprojects/ui/node_modules
doesn't have.pnpm
folder. Theprojects/ui/node_modules
as expected contains symlinks to the rootnode_modules/.pnpm
with next, react and react-dom packages.However, after I run
next build
the contents ofprojects/ui/node_modules
is modified and the.pnpm
folder appears with:[email protected][email protected][email protected][email protected][email protected]
[email protected][email protected]
The tree looks:
Almost the same contents appear in the standalone bundle itself:
So, there's clearly nothing that can resolve to
../../lib/get-network-host
.For some reason the bundle next dist directory is truncated.
The text was updated successfully, but these errors were encountered: