> ## Content Index
> Fetch the complete content index at: https://www.jonathancreamer.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Running Typescript scripts in node using esbuild
- URL: https://www.jonathancreamer.com/running-typescript-scripts-in-node-using-esbuild/
- Published: 2022-07-11T18:22:00.000Z
- Updated: 2022-07-11T18:33:17.000Z
- Description: Quickly run typescript scripts in nodejs using esbuild via the esbuild-runner package on npmjs.
- Author: Jonathan Creamer
- Tags: esbuild, tools, typescript, nodejs, node

Typescript is hands down my favorite way to write Javascript these days, but sometimes when I just want to run a quick JS script to do something, I'll still reach for `node ./foo/script.js`. I'll sometimes reach for `babel-node`\`, or `@babel/register`, but that can be pretty difficult to configure sometimes, and has some perf issues.

It does work though, and I have a post on it...

[Running Typescript programs with babel-node aka how does babel register workRunning Typescript programs on demand with babel-node basically uses babel register, but how does babel register work? This post will detail it.![](https://storage.ghost.io/c/42/63/4263df8f-a33f-403d-aa31-ba113a54d1b7/content/images/size/w256h256/2021/03/jclogo-1.png)Jonathan CreamerJonathan Creamer![](https://storage.ghost.io/c/42/63/4263df8f-a33f-403d-aa31-ba113a54d1b7/content/images/2020/12/IMG_7214.JPG)](https://www.jonathancreamer.com/running-programs-with-babel-node/)

However, I recently discovered that ESBuild has a similar mechanism to babel-node called `esbuild-runner`.

[esbuild-runnerSuper-fast on-the-fly transpilation of modern JS, TypeScript and JSX using esbuild. Latest version: 2.2.1, last published: 10 months ago. Start using esbuild-runner in your project by running \`npm i esbuild-runner\`. There are 13 other projects in the npm registry using esbuild-runner.![](https://static.npmjs.com/1996fcfdf7ca81ea795f67f093d7f449.png)npm![](https://static.npmjs.com/338e4905a2684ca96e08c7780fc68412.png)](https://www.npmjs.com/package/esbuild-runner?ref=jonathancreamer.com)

It's SUPER easy to use as well.

```
> npm i esbuild esbuild-runner
```

Then, anytime you run a `.ts` file, you do...

```
node -r esbuild-runner/register ./path/to/script.ts
```

And it's stupid fast...

![](https://storage.ghost.io/c/42/63/4263df8f-a33f-403d-aa31-ba113a54d1b7/content/images/2022/07/image-1.png)

I hope to employ `esbuild-runner` in some more local developer tooling so developers don't have to pre-compile or build their tools.