next.js: Standalone export Sharp executable is not present with pnpm
Link to the code that reproduces this issue
To Reproduce
- Set output to standalone on next.config.ts
- npm run build
- Move to standalone folder to external source for using
- node server.js
- Get “Error: ‘sharp’ is required to be installed in standalone mode for the image optimization to function correctly.”
- Move @img folder from project path node_modules to .next/standalone/node_modules
- Problem solved
Current vs. Expected behavior
When i build and use export, i get “Error: ‘sharp’ is required to be installed in standalone mode for the image optimization to function correctly.” error. I fixed it by myself at https://github.com/limanmys/website/blob/7e9d2c005e7d3197c8aecbfc98fa458a4ee40252/.github/workflows/main.yml#L45 but isn’t it supposed to move node_modules/@img folder to .next/standalone/node_modules?
Expected behavior is .next/standalone/node_modules folder to contain @img folder for Sharp after exporting but at this time it is not.
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: #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023
Binaries:
Node: 18.19.0
npm: 10.2.3
Yarn: 3.3.0
pnpm: 8.10.2
Relevant Packages:
next: 14.0.3
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: N/A
Next.js Config:
output: standalone
Which area(s) are affected? (Select all that apply)
Standalone mode (output: “standalone”)
Additional context
I also tested latest 14.0.4-canary.47 version still happens.
I am deploying to Ubuntu 22.04 with standalone export.
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 10
- Comments: 18 (3 by maintainers)
Commits related to this issue
- fix: update sharp special case for pnpm (#387) This ensures we trace child optional dependencies as well so that the symlink hierarchy is maintained for pnpm. x-ref: https://github.com/vercel/nex... — committed to vercel/nft by ijjk 5 months ago
- fix: bump `@vercel/nft@0.26.3` (#61538) - Release notes https://github.com/vercel/nft/releases/tag/0.26.3 - Fixes https://github.com/vercel/next.js/issues/59346 - Related to https://github.com/love... — committed to vercel/next.js by styfle 5 months ago
- fix: bump `@vercel/nft@0.26.3` (#61538) - Release notes https://github.com/vercel/nft/releases/tag/0.26.3 - Fixes https://github.com/vercel/next.js/issues/59346 - Related to https://github.com/lovell... — committed to vercel/next.js by styfle 5 months ago
Try using version 0.32.6 of Sharp
https://github.com/limanmys/website/blob/7e9d2c005e7d3197c8aecbfc98fa458a4ee40252/.github/workflows/main.yml#L45
@rusted-love I fixed it temporarily with this way.
Same here. Deploying with Docker + DigitalOcean App Platform. Docker configs based on official examples have the same error.
Looks like the issue in this case was pnpm has slightly different node_modules behavior than npm so some of the relevant binary files were not copied correctly.
This will be fixed in https://github.com/vercel/next.js/pull/61538 thanks!
It should already be fixed in v14.0.5-canary.36
Same in standalone mode, I had to revert to 0.32.6
These are the related issues/prs: