Use tsx instead of nodemon

rennycat

Jaruwat Thongchana

Posted on October 7, 2022

Use tsx instead of nodemon

If you use typescript, nodemon and ts-node for development.
You'll notice that it takes a while to recompile the code when it changes.

tsx is a Typescript execute which blazing fast ⚡️ with esbuild.

Installation

I prefer use pnpm but you can use npm, yarn, ...etc.

pnpm add -D tsx
Enter fullscreen mode Exit fullscreen mode

Now you can uninstall nodemon and ts-node.

pnpm remove nodemon ts-node
Enter fullscreen mode Exit fullscreen mode

Add script tsx watch [file/folder] in the package.json.

{
  "name": "use-tsx",
  "version": "1.0.0",
  "main": "index.ts",
  "scripts": {
    "dev": "tsx watch src",
  },
  "devDependencies": {
    "@types/node": "^18.7.18",
    "tsx": "^3.9.0",
    "typescript": "^4.8.3",
  }
}
Enter fullscreen mode Exit fullscreen mode

Let's start.

pnpm dev
Enter fullscreen mode Exit fullscreen mode

refs:

💖 💪 🙅 🚩
rennycat
Jaruwat Thongchana

Posted on October 7, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Use tsx instead of nodemon
node Use tsx instead of nodemon

October 7, 2022