Vercel/og porting to Replit

Hey, I’m trying to port this @vercel/og example to Replit: Open Graph (OG) Image Generation | Vercel Docs

I copied and pasted the code here:

But it throws errors like “SyntaxError: Cannot use import statement outside a module” however I try and modify it…

Forgive me, I’m just getting my head around node.js so this could be an extremely simple thing sorry! And thanks :slight_smile:

Hey @TomCritchlow! Welcome to the forums!

Node.js uses require() for imports and module.exports for exports. The ES import and export keywords don’t work in Node.js.


Try adding "type": "module" to your package.json. It’s probably that simple.