SynaxError: Unexpected Token export
I am trying to run my code that imports some types from "@cloudflare/workers-types" but it gives me this error
Its a monorepo and am using simple ts-node to run my index file. This file imports a local package that in turn imports from "cloudflare/workers-types".
3 Replies
Could it be that you're missing
"type": "module"
from your package.json?
I think ts-node defaults to cjs if type is not explicitly declared, and esm imports/exports don't work therenvm i fixed it
i didnt need to import them
adding "types": ["@cloudflare/workers-types"] did that
on a global level
yup, for most use cases you should be fine with that, although I recommend using a "newer" entrypoint
the default one points to the oldest date, if you check here https://www.npmjs.com/package/@cloudflare/workers-types#compatibility-dates I recommend appending the date that is the newest out of those still older than your specified compatibility date