Strange require() not supported, @auth/express with Typescript error #11417
Replies: 1 comment 1 reply
-
Does your package.json have "type": "module"?. You might also need NodeNext instead of commonjs in tsconfig for module. Check the example app You will also need to add .js file extensions to imports of your own files: Lastly, to run the dev server, use tsx instead of ts-node. It's probably the easiest way to run typescript in node and faster than ts-node (mainly because it doesn't type check). Just using tsx will probably fix all your issues anyway without having to change imports and configs. It's still probably worth fixing that stuff so you can do a normal tsc compile and run with node in production, because you shouldn't use tsx in prod. Otherwise, if you dont want to change your import and configs, you might be able to compile with pkgroll, but I've never tried. For a new project definitely just use ESM. If you want type checking when running the dev server, you have to use the ts-node esm loader: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Throwing an exception when trying to use auth/express with Typescript.
server.ts
:ts-config.json
:Run with
ts-node server.ts
Potentially related to https://stackoverflow.com/questions/70800567/return-oldm-filename-error-err-require-esm-require-of-es-module but I can't seem to fix. Any thoughts?
Beta Was this translation helpful? Give feedback.
All reactions