next.js: Module not found: Can't resolve 'next/og'

Link to the code that reproduces this issue

https://github.com/wiscaksono/wiscaksono-site/tree/og-images

To Reproduce

  1. Deploy it on vercel

Current vs. Expected behavior

image

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:42:57 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T8112
Binaries:
  Node: 18.18.0
  npm: 10.2.3
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.0.1
  eslint-config-next: 14.0.1
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

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

Routing (next/router, next/navigation, next/link)

Additional context

I just want to deploy my fresh next app to the vercel, and then failed to compile, even am using the latest next js (14.0.1), it works when i build on my local machine, but not works on the vercel.

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

ImageResponse should be imported from next/og in next@14, should be imported from next/server in next@13. Can you make sure it’s imported correctly in your app? If it doesn’t work can you share a reproduction?

I couldn’t repro the issue on vercel by simplifying the reproduction from this issue https://github.com/vercel/next.js/issues/58252#issuecomment-1814307016

maybe there are still bugs in next/og, but now I use @vercel/og and it works fine and without problems at least for now.

I found a workaround - add @vercel/og and import that, eg. import { ImageResponse } from "@vercel/og";