-
-
Notifications
You must be signed in to change notification settings - Fork 533
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)
I'm on node v 20.18.0 and encountering this issue. After reading through the entire thread it's unclear to me what the overall accepted solution to this issue is...or if there isn't one still. Can someone provide a little clarity? Thanks. |
Does the following script work for you (it does type checking and then runs ts-node with ESM support)? tsc --noEmit && node --no-warnings=ExperimentalWarning --loader ts-node/esm ./src/start.ts |
@bennycode I saw it was a temporary fix but didn't try it because I saw a couple replies saying it ate up their CPU. Is that just the workaround at this point? |
this issue has been open for an year and a half, and yet, seemingly, no progress has been made on it. ESM is probably the ONE thing this project should get right, and this is a CRITICAL issue. how in the livid hell does this happen. |
@bennycode This may require this fix nodejs/node#48207 (comment) |
seems unsolvable i hope the official will open a replacement issue |
(@septs is this issue's reporter, not a ts-node maintainer) |
ts-node is dead, use bun instead. Just switch, faster and easier |
so far it seems that tsx is the go-to replacement, we should abandon this software like its creators did. also @phosmium can we stop with the shilling of alternative runtimes, because, as good as bun may be, it is just not available as an option to some of us |
@bisubus Great idea to pair |
@TopchetoEU tsx isn't a full replacement and doesn't have type checks, I'm a bit sceptical about their development model privatenumber/tsx#671 . Not even accepting contributions without a donation? |
I still think tsimp is a better replacement. |
lol this is gold. nodejs should stop recommending this. |
Why do you think so? I ran into multiple issues when using it: tapjs/tsimp#26 |
Oh, because it typechecks using tsc. That's why. |
good point, but at least it still works with ESM. |
tsimp is great in theory, but it's extremely buggy, and can produce non-obviously stale results from because of caching bugs. |
|
…#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.
I created a video summarizing how to run The |
Showcase of the problem: demo.mp4Here's all the loaders webpack supports
Webpack will check them in that order, mind you. So even if you have So I just did (I use Yarn package manager, if you use NPM translate these commands to their equivalent)
and then
No more configuration is needed (I don't have Another thing, if you do not have
|
This worked for me. By far the best solution I have come across. :) |
Well, if there's anything positive out of it, I hope it somehow incentivize people to try a better runtime like Deno or Bun. |
unfortunately, sometimes you don't get to pick your runtime, and you're forced to use NodeJS, despite your best wishes. |
I've switched to Deno, but there are still some rough edges, especially when it comes to testing:
Also, there's no interop with ESLint rules, and Deno's built-in linting is just not up to par with typescript-eslint. |
Deno is still buggy... Bun too... Those nasty bugs are so annoying to find out later in the production.. |
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: