Live data from Hacker News

Node.js is able to execute TypeScript files without additional configuration

nodejs.org

131–140 of 275 posts

Re: Node.js is able to execute TypeScript files without additional configuration

#131

I’m not a heavy JS/TS dev so here’s an honest question: why not use Bun and forget about node? Sure I understand that not every project is evergreen but isn’t Bun a much runtime in general? It supports TS execution from day 1, has much faster dependency resolution, better ergonomics… and I could keep going. I know I’m just a single data point but I’ve had a lot of success migrating old node projects to bun (in fact I…

I have tried fully switching to bun repeatedly since it came out and every time I got 90% of the way there only to hit a problem that couldn't be worked around. Last I tried I was still stuck on some libraries requiring napi functions that weren't implemented in bun yet, as well an issue I forget but it was vaguely something like `opendir` silently ignoring the `recursive` option causing a huge headache.

I'm waiting patiently for bun to catch up because I would love to switch but I don't think its ready for production use in larger projects yet. Even when things work, a lot of the bun-specific functionality sounds nice at first but feels like an afterthought in practice, and the documentation is far from the quality of node.js

Re: Node.js is able to execute TypeScript files without additional configuration

#132
This is great up until you get to the fact that typescript will not be accepted under node_modules [0].

That leads me to ask, what about project dependencies? I wrote a lib for my data models in typescript and I want to import that into my app in node, in typescript? Does the rule only apply to npm packages? There’s opportunity here…

I wrote a runtime in golang that runs typescript (well, JavaScript in general). The grafana folks have sobek that all they need is to add type striping. I feel like if there’s one runtime where typescript could be adopted fully and it would change the world is Node.js. No transpiler, no typescript-go, no rust (well, maybe some rust ;) just a great parser that will keep track of the source map and types in debug mode (for tracing).

Either way, kudos to the node team, contributors, for pulling in the goal posts to make the kick to launch shorter. I’m still a fan of bun, and my own runtime, but node is the standard by which we all are kinda following. I also like that the embedding api is simple and clean to use now so if you want to make an executable, you can.

[0] https://nodejs.org/api/typescript.html#type-stripping-in-dep...

Re: Node.js is able to execute TypeScript files without additional configuration

#133

https://github.com/nodejs/node/issues/57215 Not supporting type stripping in node_modules is unfortunate

But... that's like half the reason why I wanted this feature... Writing a library in TypeScript (with typechecks in CI/CD as devDependencies) and just importing it directly from Node.js...

It was the first thing I tried and of course it didn't work.

It might finally be time to switch to Deno or Bun =(

Re: Node.js is able to execute TypeScript files without additional configuration

#134

I’m not a heavy JS/TS dev so here’s an honest question: why not use Bun and forget about node? Sure I understand that not every project is evergreen but isn’t Bun a much runtime in general? It supports TS execution from day 1, has much faster dependency resolution, better ergonomics… and I could keep going. I know I’m just a single data point but I’ve had a lot of success migrating old node projects to bun (in fact I…

I tried to replace Node with Bun, but had the following compatibility problems.

localAddress on TCP connections ignored, last time I tried it its no-op

Incompatibility with Node module APIs (https://github.com/spamscanner/spamscanner wouldn't work)

EventEmitter race problems (partially worked around with https://www.npmjs.com/package/eventemitter2)

Svelte vites dev server sometimes forever freeze until I wiped node_modules and reinstalled it.

Re: Node.js is able to execute TypeScript files without additional configuration

#135

This is great up until you get to the fact that typescript will not be accepted under node_modules [0]. That leads me to ask, what about project dependencies? I wrote a lib for my data models in typescript and I want to import that into my app in node, in typescript? Does the rule only apply to npm packages? There’s opportunity here… I wrote a runtime in golang that runs typescript (well, JavaScript in general). The…

I made the same comment here https://news.ycombinator.com/item?id=44931575

"To discourage package authors from publishing packages written in TypeScript"

I tried to use it with private packages but that doesn't work either, apparently node doesn't even read the "private" field.

Re: Node.js is able to execute TypeScript files without additional configuration

#136

I’m not a heavy JS/TS dev so here’s an honest question: why not use Bun and forget about node? Sure I understand that not every project is evergreen but isn’t Bun a much runtime in general? It supports TS execution from day 1, has much faster dependency resolution, better ergonomics… and I could keep going. I know I’m just a single data point but I’ve had a lot of success migrating old node projects to bun (in fact I…

For me - it doesn't support secure and reliable dependency vendoring.

The best way to do this atm. is using (and configuring) yarn for zero-installs.

This keeps dependencies inside the codebase so that: * Issues can be easily traced to the code that actually ran - development and deployment are the same. * Deployment doesn't depend on package repositories. * Deployment is secure from many kinds of attacks. * It is possible to transparently patch packages. * Development is only internet dependent when adding a new package. * and the best ease-of-use - no reinstall when changing branches.

Re: Node.js is able to execute TypeScript files without additional configuration

#137

This is great up until you get to the fact that typescript will not be accepted under node_modules [0]. That leads me to ask, what about project dependencies? I wrote a lib for my data models in typescript and I want to import that into my app in node, in typescript? Does the rule only apply to npm packages? There’s opportunity here… I wrote a runtime in golang that runs typescript (well, JavaScript in general). The…

I made the same comment here https://news.ycombinator.com/item?id=44931575 "To discourage package authors from publishing packages written in TypeScript" I tried to use it with private packages but that doesn't work either, apparently node doesn't even read the "private" field.

It’s a missed opportunity for sure

Re: Node.js is able to execute TypeScript files without additional configuration

#138
post #96
post #68

Earlier quoted context omitted.

22 is LTS. The future is now.

Sure, who is going to budget project upgrade effort of ensuring all dependencies work equally as well? There is a reason why so many Java, Python, .NET/C#, C, C++,.. projects are stuck several versions behind.

No one said developing software wasn't going to be work.

Re: Node.js is able to execute TypeScript files without additional configuration

#139
post #26

Earlier quoted context omitted.

What are the recent improvements in node itself? Last actually note-worthy improvement I heard of was properly supporting import/export (although do you still need to use the .mjs hack?), but I've been out of the loop here for sometime so would be nice to know what they've added since.

Here’s a nice overview: https://kashw1n.com/blog/nodejs-2025/ It doesn’t cover everything, but as an old-school Node user I found several interesting features I didn’t know about.

That is a nice article. It does a great job summing thing up with real examples too.

Re: Node.js is able to execute TypeScript files without additional configuration

#140

I think this + node:test makes Node.js a pretty compelling sensible default for most things now. Running things with `tsx` was such a QoL improvement when it happened, but it didn't solve everything. Runtime type assertion at the edges is mostly solved through `zod` and tools like `ts-rest` and `trpc` makes it so much easier to do full-stack Typescript these days.

This. It's 2025 and the node ecosystem is finally usable by default! ESM modules just work with both Node and Typescript, Node can run .ts files, and there's the a good enough test runner built in. --watch. The better built in packages - `node:fs/promises` - are nice with top-level await for easier async loops. It took a while to convince everyone involved to just be pragmatic, but it's nice now.

This is great to hear, but perhaps comes too late for people like myself. Node.js has been by go-to platform from around 2014 until last year. But around September last year, I found myself thrust into the .NET ecosystem (due to a client project). Within a few months, I realized that it too, had finally become usable by default (unlike the last time I tried it, when it was too tightly coupled to Windows). In fact, it felt like what Node.js would be, if it had strong typing built-in, and had a good standard library that eliminated a lot of the module management and churn. I'm now finding it hard to return to Node.js.
Post reply on HN