Skip to content

[BUG] pnpm symlink compatibility #414

@ha1fstack

Description

@ha1fstack

Describe the bug

┌──────────────────────────────┐
│ OpenNext — Generating bundle │
└──────────────────────────────┘

Bundling middleware function...
Bundling static assets...
Bundling cache assets...
Building server function: default...
node:fs:3086
  binding.copyFile(
          ^

Error: EPERM: operation not permitted, copyfile '...\.next\standalone\node_modules\.pnpm\[email protected]\node_modules\@img\sharp-wasm32' -> '...\.open-next\server-functions\default\node_modules\.pnpm\[email protected]\node_modules\@img\sharp-wasm32'
    at copyFileSync (node:fs:3086:11)
    at file:///.../node_modules/.pnpm/@opennextjs+aws@https+++pkg.pr.new+@opennextjs+aws@748/node_modules/@opennextjs/aws/dist/build/copyTracedFiles.js:140:13
    at Map.forEach (<anonymous>)
    at copyTracedFiles (file:///.../node_modules/.pnpm/@opennextjs+aws@https+++pkg.pr.new+@opennextjs+aws@748/node_modules/@opennextjs/aws/dist/build/copyTracedFiles.js:111:17)
    at generateBundle (file:///.../node_modules/.pnpm/@opennextjs+cloudflare@https+++pkg.pr.new+@opennextjs+cloudflare@[email protected]_@cl_kqmgsg5g3b7oqvmpys6frm3g2a/node_modules/@opennextjs/cloudflare/dist/cli/build/open-next/createServerBundle.js:106:11)
    at createServerBundle (file:///.../node_modules/.pnpm/@opennextjs+cloudflare@https+++pkg.pr.new+@opennextjs+cloudflare@[email protected]_@cl_kqmgsg5g3b7oqvmpys6frm3g2a/node_modules/@opennextjs/cloudflare/dist/cli/build/open-next/createServerBundle.js:66:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async build (file:///.../node_modules/.pnpm/@opennextjs+cloudflare@https+++pkg.pr.new+@opennextjs+cloudflare@[email protected]_@cl_kqmgsg5g3b7oqvmpys6frm3g2a/node_modules/@opennextjs/cloudflare/dist/cli/build/build.js:74:5)
    at async file:///.../node_modules/.pnpm/@opennextjs+cloudflare@https+++pkg.pr.new+@opennextjs+cloudflare@[email protected]_@cl_kqmgsg5g3b7oqvmpys6frm3g2a/node_modules/@opennextjs/cloudflare/dist/cli/index.js:7:1 {
  errno: -4048,
  code: 'EPERM',
  syscall: 'copyfile',
  path: '...\\.next\\standalone\\node_modules\\.pnpm\\[email protected]\\node_modules\\@img\\sharp-wasm32',
  dest: '...\\.open-next\\server-functions\\default\\node_modules\\.pnpm\\[email protected]\\node_modules\\@img\\sharp-wasm32'
}

Node.js v22.14.0

Steps to reproduce

  • pnpm latest, node lts, windows
  • nextjs starter template

pnpm with node-linker=isolated breaks build

  1. throws EPERM error while build
  2. node_modules folder gets corrupted so have to reinstall dependency from scratch everytime I build

If switched to node-linker=hoisted so symlink is disabled, the problems are gone

tested on windows only, guess other platforms are fine

Expected behavior

  • build should work
  • node_modules folder should be intact

@opennextjs/cloudflare version

latest stable / canary

Wrangler version

3.109.3

next info output

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Education
  Available memory (MB): 65278
  Available CPU cores: 24
Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.5.0
Relevant Packages:
  next: 15.1.7 // Latest available version is detected (15.1.7).
  eslint-config-next: 15.1.7
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions