examples icon indicating copy to clipboard operation
examples copied to clipboard

Im trying to use grammy on my next.js project but whatever i do i get this

Open MateoKappa opened this issue 1 year ago • 6 comments

`npx ts-node scripts/build.ts

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/mateokappa/Desktop/www/scripts/build.ts at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9) at defaultGetFormat (node:internal/modules/esm/get_format:203:36) at defaultLoad (node:internal/modules/esm/load:141:22) at async nextLoad (node:internal/modules/esm/hooks:865:22) at async nextLoad (node:internal/modules/esm/hooks:865:22) at async Hooks.load (node:internal/modules/esm/hooks:448:20) at async MessagePort.handleMessage (node:internal/modules/esm/worker:196:18) { code: 'ERR_UNKNOWN_FILE_EXTENSION' }`

MateoKappa avatar Apr 09 '24 18:04 MateoKappa

How is this related to grammY?

KnorpelSenf avatar Apr 10 '24 08:04 KnorpelSenf

The build script is from the next.js example from Grammy and I can't run it on my next JS project

MateoKappa avatar Apr 10 '24 10:04 MateoKappa

AFAIK, you don't have to run this command anyway. It will be run automatically during build.

@PonomareVlad is there a way to run these things locally? Should we document it, given that people try it anyway?

KnorpelSenf avatar Apr 10 '24 11:04 KnorpelSenf

It is also failing on vercel , basically I'm trying to fix it locally so it fixes while running on vercel as well

MateoKappa avatar Apr 10 '24 11:04 MateoKappa

ts-node doesn't support .ts extension ? 🌚

PonomareVlad avatar Apr 10 '24 12:04 PonomareVlad

I had the same error, and switched from ts-node to tsx.

But if you want to use ts-node, see this issue: https://github.com/TypeStrong/ts-node/issues/2100

Also, you can just use Bun, it's very fast.

You can do this: bun run scripts/build.ts, not required ts-node.

keyding avatar Sep 01 '24 03:09 keyding