Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active April 28, 2024 03:47
Show Gist options
  • Star 99 You must be signed in to star a gist
  • Fork 50 You must be signed in to fork a gist
  • Save Klerith/3ba17e86dc4fabd8301a59699b9ffc0b to your computer and use it in GitHub Desktop.
Save Klerith/3ba17e86dc4fabd8301a59699b9ffc0b to your computer and use it in GitHub Desktop.
Node con TypeScript - TS-Node-dev simplificado

Node con TypeScript - TS-Node-dev (preferido)

  1. Instalar TypeScript y demás dependencias
npm i -D typescript @types/node ts-node-dev rimraf
  1. Inicializar el archivo de configuración de TypeScript ( Se puede configurar al gusto)
npx tsc --init --outDir dist/ --rootDir src
  1. Crear scripts para dev, build y start (Más sobre TS-Node-dev aquí)
  "dev": "tsnd --respawn --clear src/app.ts",
  "build": "rimraf ./dist && tsc",
  "start": "npm run build && node dist/app.js"
@imnotUrban
Copy link

Genial, muchas gracias. Para los que les dé error del tipo rootDir en el tsconfig.json, con que le agreguen esto se arregla:

"exclude": ["node_modules","dist" ],
"include": ["src"],

@codewithleader
Copy link

Excelente material! Gracias por compartir 💯 🏗️

@codeConqueror7
Copy link

Un saludo Fernando

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment