New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERR_UNKNOWN_FILE_EXTENSION on Node v20.0.0 #1997
Comments
Edited by 11/18/2023 Use tsx replace ts-node? Or use ts-node@beta? more see https://github.com/privatenumber/tsx, #2077 |
I have the same issue. I tried using |
FYI Node 20 has made a breaking change:
|
+1 The issue also appears when using the specially dedicated ESM runner
|
Revert once TypeStrong/ts-node#1997 is resolved.
I went forward and downgraded my node version to |
i expirience the same issue on: # node --version
v18.16.0 EDIT: {
"start": "npm run clean && cross-env NODE_ENV=development NODE_OPTIONS=\"--loader=ts-node/esm --trace-warnings\" webpack serve --mode=development --config webpack.config.ts",
} worked out. example sourced from here: |
i expirience the same issue on: Node v20, |
I'd like to add quickly that on windows (at least), doing |
Yes, |
yeah, I recently upgraded to node 20 and started running with the So I'd recommend people stay off Node 20 until this is fixed if you don't want to have unexpected issues in your runtime. |
Node 20 changed experimental loaders. Fix running tests on node 20: * https://nodejs.org/en/blog/announcements/v20-release-announce * TypeStrong/ts-node#1997 * avajs/ava#2593 (comment)
The current start command fails with node 20 or node 18.9. This seems to be an issue related to the node --loader flag: TypeStrong/ts-node#1997 Was able to get around it by calling ts-node directly on index.ts and run the validators
This is horrible. It's been such a long time now and this is still unfixed. @blakeembrey |
Had problems with ts-node on Node 20 so needed to use something else TypeStrong/ts-node#1997
Since ESM loader hookers now run on a dedicated thread, load the esm module from node directly: TypeStrong/ts-node#1997 (comment)
Since ESM loader hookers now run on a dedicated thread, load the esm module from node directly: TypeStrong/ts-node#1997 (comment)
Since ESM loader hookers now run on a dedicated thread, load the esm module from node directly: TypeStrong/ts-node#1997 (comment)
My solution was to use |
I'd recommend tsx as alternative, @phosmium && @PrimalZed . |
On the other hand, tsx lacks type checking. tsimp may be a better drop-in replacement than tsx. |
…te:config. This likely broke when upgrading node at some point. Found a suggestion on TypeStrong/ts-node#1997 to just use tsx, which works! Part of #688.
You can do with just
|
So does ts-node when used with |
you can do |
Regardless of preferences, ts-node type checks by default and therefore tsimp is a better drop-in replacement to ts-node than tsx since it behaves the same as ts-node by default (I'm not taking into account when used with swc). If you don't need type checking, then go with tsx of course. But, for example, my use case needs type checking when executing the application. |
|
I got my "npm run start" script to work with nodemon this way if this helps anyone: "start": "nodemon --exec node --no-warnings=ExperimentalWarning --loader ts-node/esm src/server.ts" Replace "src/server.ts" with the path to the file you want to execute. |
Awesome this was the easiest workaround, instead of reading all of this useless technical mumbo-jumbo discussion. |
How can I specify the tsconfig when using node --loader ts-node/esm ./myscript.mts |
This issue may be a good excuse to try Deno or Bun instead, btw. |
In the end I went with tsx, 0 config and having a separate |
…#1977) This pull request resolves #1926 and prevents issues like it from happening in the future ## Rationale for this PR This PR changes the TypeScript execution package for use in scripts like `build:registry` from `ts-node` to `tsx`. This is because `ts-node` has many difficult quirks to work through (and is slow). In addition, it also has a difficult to understand error for newcomers that *is* reproducible. ### The ts-node error As shown in #1926, using `ts-node` (specifically in `build:registry`) results in this error: `Unknown file extension ".ts" for /ui/apps/www/scripts/build-registry.ts`. There are many issues in the `ts-node` repository documenting this problem: * TypeStrong/ts-node/issues/1062 * TypeStrong/ts-node/issues/2033 * TypeStrong/ts-node/issues/1997 Switching the typescript-in-node system to `tsx`, which uses esbuild under the hood, resolves this error. This PR shouldn't affect tests, representation, etc. and is merely a change of build tools. There is no urgent need to merge this. I accidentally deleted the head repository on #1937. That will not happen again.
…#1977) This pull request resolves #1926 and prevents issues like it from happening in the future ## Rationale for this PR This PR changes the TypeScript execution package for use in scripts like `build:registry` from `ts-node` to `tsx`. This is because `ts-node` has many difficult quirks to work through (and is slow). In addition, it also has a difficult to understand error for newcomers that *is* reproducible. ### The ts-node error As shown in #1926, using `ts-node` (specifically in `build:registry`) results in this error: `Unknown file extension ".ts" for /ui/apps/www/scripts/build-registry.ts`. There are many issues in the `ts-node` repository documenting this problem: * TypeStrong/ts-node/issues/1062 * TypeStrong/ts-node/issues/2033 * TypeStrong/ts-node/issues/1997 Switching the typescript-in-node system to `tsx`, which uses esbuild under the hood, resolves this error. This PR shouldn't affect tests, representation, etc. and is merely a change of build tools. There is no urgent need to merge this. I accidentally deleted the head repository on #1937. That will not happen again.
Search Terms
Node, ERR_UNKNOWN_FILE_EXTENSION
Expected Behavior
Fix it
Actual Behavior
see Minimal reproduction
Steps to reproduce the problem
see Minimal reproduction
Minimal reproduction
Specifications
ts-node version: 10.9.1
node version: 20.0.0
TypeScript version: 5.0
tsconfig.json:
package.json:
Operating system and version: macOS 13.3.1
The text was updated successfully, but these errors were encountered: