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

Issue with sharp optional peer dependency with Payload admin introduced since canary.7 #65247

Closed
paulpopus opened this issue May 1, 2024 · 1 comment · Fixed by #65484
Closed
Labels
bug Issue was opened via the bug report template. Module Resolution Module resolution (CJS / ESM, module resolving) Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@paulpopus
Copy link

Link to the code that reproduces this issue

https://github.com/paulpopus/nextjs-payload-sharp-issue

To Reproduce

Ensure that you have .env available with the database and payload secret configured, you will need a mongo db running for which you can use a remote DB or the provided docker compose file

DATABASE_URI=mongodb://127.0.0.1/fresh-payload
PAYLOAD_SECRET=f4cd94b2c27475da3466ca44

Then run yarn dev and try to access localhost:3000/admin.

When running nextjs canary version 7 it will work, however newer version of canary have introduced an optional sharp dependency that does not resolve correctly with these package managers and will not work.

So to be clear, change the package.json dependency to canary.34 for next and it will break after installing dependencies again.

I see this issue happen with yarn v1 and pnpm v8 equally

Current vs. Expected behavior

Current
When accessing /admin I see a sharp missing error

Error: Could not load the "sharp" module using the linux-x64 runtime

Expected
When accessing /admin I expect the admin panel to work

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #202403110203~1714077665~22.04~4c8e9a0 SMP PREEMPT_DYNAMIC Thu A
  Available memory (MB): 31782
  Available CPU cores: 20
Binaries:
  Node: 20.9.0
  npm: 10.1.0
  Yarn: 1.22.21
  pnpm: 8.15.8
Relevant Packages:
  next: 14.3.0-canary.7 // There is a newer canary version (14.3.0-canary.34) available, please upgrade! 
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Module Resolution, Runtime

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

"next": "14.3.0-canary.7" works
"next": "14.3.0-canary.34" does not work

canary.7 did not have sharp listed as a dependency and one of the versions since then has introduced it

@paulpopus paulpopus added the bug Issue was opened via the bug report template. label May 1, 2024
@github-actions github-actions bot added Module Resolution Module resolution (CJS / ESM, module resolving) Runtime Related to Node.js or Edge Runtime with Next.js. labels May 1, 2024
xHomu added a commit to manawiki/repay that referenced this issue May 6, 2024
Waiting for vercel/next.js#65247 before bumping next
@paulpopus
Copy link
Author

Yeah we tracked it down and had a discussion, thanks for the link ^

Closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Module Resolution Module resolution (CJS / ESM, module resolving) Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant