NodeJS typescript rechargement automatique simple sur changement de fichier

Installez d’abord ts-node-dev :

npm i –save-dev ts-node-dev

install_tsnd.sh
npm i --save-dev ts-node-dev

Puis ajoutez

package.json.snippet
"start": "./node_modules/.bin/tsnd --respawn app.ts"

à package.json dans la section scripts, exemple :

package.json.example.json
{
  "name": "myapp-backend",
  "version": "1.0.0",
  "description": "To make it easy for you to get started with GitLab, here's a list of recommended next steps.",
  "main": "index.js",
  "scripts": {
    "build": "./node_modules/.bin/tsc -b tsconfig.json",
    "start": "./node_modules/.bin/tsnd --respawn app.ts"
  }
  /* ... */
}

Consultez les articles similaires par catégorie : JavaScript NodeJS