jasonraimondi / ts-oauth2-server-example

This is an example implementation of the @jmondi/oauth2-server project using a NestJS/Express server and a Sveltekit client. This is supposed to be a more real example of how to implement the package in a production application.
https://github.com/jasonraimondi/ts-oauth2-server
MIT License
9 stars 2 forks source link

pnpm db:seed fails with Unknown file extension ".ts" #6

Closed michielbdejong closed 1 month ago

michielbdejong commented 1 month ago

Hi!

I get the following error on my system:

$ pnpm db:seed

> jmondi-oauth2-example-server@ db:seed /Users/michiel/gh/jasonraimondi/ts-oauth2-server-example
> ts-node --esm prisma/seed.ts

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/michiel/gh/jasonraimondi/ts-oauth2-server-example/prisma/seed.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:143: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'
}
 ELIFECYCLE  Command failed with exit code 1.

I'll poke around to see what might be causing this, probably a problem with how my system is set up, but wanted to report it nonetheless, for reference.

I'm using a Macbook with ts-node version 10.9.1 and node version 20.11.0

michielbdejong commented 1 month ago

Hm, I was using node and pnpm through Volta, switching to nvm and npm respectively now to see if that fixes it. Also switching from node 20 to node 18 to see if that helps.

michielbdejong commented 1 month ago

The problem also happens on GitPod so it seems to be unrelated to my laptop setup

michielbdejong commented 1 month ago

It also happens when you ts-node empty.ts an empty file. If you delete package.json then it works!

michielbdejong commented 1 month ago

Specifically, removing this line from package.json fixes it.

michielbdejong commented 1 month ago

Ah! https://stackoverflow.com/a/75990537/680454 fixes this. I'll create a PR.

michielbdejong commented 1 month ago

Hm, I saw this working on GitPod with Node 16 but having some trouble generalising the result. Investigating further...

michielbdejong commented 1 month ago

Fixed in #7

jasonraimondi commented 1 month ago

Thank you for looking into this and figuring out a resolution, this was next on my list! Are you all good or is there anything else I can help out with or help make more clear? If you have any suggestions to on documentation or anything, totally open to it!

michielbdejong commented 1 month ago

All good, thanks! Thank you for this project and for merging the PR!