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: https://replit.com/@TomCritchlow/og-verccel-test

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.

2 Likes

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