Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone export Sharp executable is not present with pnpm #59346

Closed
1 task done
dogukanoksuz opened this issue Dec 7, 2023 · 18 comments · Fixed by #61538
Closed
1 task done

Standalone export Sharp executable is not present with pnpm #59346

dogukanoksuz opened this issue Dec 7, 2023 · 18 comments · Fixed by #61538
Labels
bug Issue was opened via the bug report template. locked Output (export/standalone) Related to the the output option in `next.config.js`.

Comments

@dogukanoksuz
Copy link

Link to the code that reproduces this issue

https://github.com/limanmys/website/blob/7e9d2c005e7d3197c8aecbfc98fa458a4ee40252/.github/workflows/main.yml#L45

To Reproduce

  1. Set output to standalone on next.config.ts
  2. npm run build
  3. Move to standalone folder to external source for using
  4. node server.js
  5. Get "Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly."
  6. Move @img folder from project path node_modules to .next/standalone/node_modules
  7. 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.

@dogukanoksuz dogukanoksuz added the bug Issue was opened via the bug report template. label Dec 7, 2023
@github-actions github-actions bot added the Output (export/standalone) Related to the the output option in `next.config.js`. label Dec 7, 2023
@l-you
Copy link

l-you commented Dec 7, 2023

Same here. Deploying with Docker + DigitalOcean App Platform.
Docker configs based on official examples have the same error.

@dafengzhen
Copy link

Try using version 0.32.6 of Sharp

@dogukanoksuz
Copy link
Author

Same here. Deploying with Docker + DigitalOcean App Platform. Docker configs based on official examples have the same error.

https://github.com/limanmys/website/blob/7e9d2c005e7d3197c8aecbfc98fa458a4ee40252/.github/workflows/main.yml#L45

@rusted-love I fixed it temporarily with this way.

@lovell
Copy link
Contributor

lovell commented Dec 7, 2023

This is caused by vercel/nft#371

@Hyodori04
Copy link

Same here. I think sharp version is related.

@chrisneven
Copy link
Contributor

Try using version 0.32.6 of Sharp

Yes, this works for us. Hopefully, it's a temporary solution...

@duvillierA why did you downvote?

@ui-jb
Copy link

ui-jb commented Dec 13, 2023

I tried version 0.32.6 of Sharp, but it unfortunately didn't resolve the issue for my project

EDIT:
It turns out a Dockerfile was overriding the version of sharp specified in our package.json.
After resolving that, I can confirm that reverting to 0.32 has resolved the issue.

@kasem-sm
Copy link

I tried version 0.32.6 of Sharp, but it unfortunately didn't resolve the issue for my project

v0.32.6 doesn't works for me as well :/

@Hyodori04
Copy link

@ui-jb @kasem-sm

standalone + sharp 0.32.6 not working? It works for me

@ui-jb
Copy link

ui-jb commented Dec 27, 2023

@ui-jb @kasem-sm

standalone + sharp 0.32.6 not working? It works for me

I've updated my previous comment as it turned out a Dockerfile was overriding the version of sharp specified in our package.json.
I can now confirm that reverting to version 0.32 of sharp resolves the issue.

@marc0olo
Copy link

finally found that issue here 🙏 any ETA to get the issue resolved? I assume a lot of people running in standalone mode will face this issue 😅

@darthmaim
Copy link
Contributor

finally found that issue here 🙏 any ETA to get the issue resolved? I assume a lot of people running in standalone mode will face this issue 😅

It should already be fixed in v14.0.5-canary.36

@marc0olo
Copy link

It should already be fixed in v14.0.5-canary.36

good to know, thanks! wondering why the fix isn't linked to this issue 🤔

@FredTreg
Copy link

Same in standalone mode, I had to revert to 0.32.6

@naminator
Copy link

naminator commented Jan 17, 2024

This worked for me using Next v12.2.0 and Yarn v1.
yarn add [email protected] --ignore-engines.

Took a while to figure this out, but it says in their installation instructions that if you're using yarn v1, you should install with --ignore-engines.

https://sharp.pixelplumbing.com/install

styfle added a commit to vercel/nft that referenced this issue Feb 1, 2024
This ensures we trace child optional dependencies as well so that the
symlink hierarchy is maintained for pnpm.

x-ref: vercel/next.js#59346
x-ref: lovell/sharp#3967

---------

Co-authored-by: Steven <[email protected]>
@styfle styfle changed the title Standalone export Sharp executable is not present on node_modules folder Standalone export Sharp executable is not present with pnpm Feb 1, 2024
@styfle
Copy link
Member

styfle commented Feb 1, 2024

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 #61538 thanks!

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Output (export/standalone) Related to the the output option in `next.config.js`.
Projects
None yet
Development

Successfully merging a pull request may close this issue.