Do I need to run "npm run build" every time I made changes?

Use this command:

tsc src/index.ts --watch --outDir ./lib


So finally, I have found my solution. When you want to re-run "npm run build" every time a file changes. You need to install watch via npm. It checks all the files inside a directory and when you change something or on-save, it will re-run all the scripts inside package.json. So steps -

  1. Install watch by "npm install watch"
  2. When watch is installed, add "watch": "watch 'npm run build' ./directory-you-want-to-track"
  3. Run "npm run watch"