0

This is how I run a A.ts file:

npm run start_A

where I have in package.json:

  "scripts": {
    "win_dev": "set NODE_ENV=development  && concurrently --kill-others \"tsc-watch --project ./\" \"nodemon dist/index.js\"",
    "dev": "set NODE_ENV=development && node dist/server.js",
    "test": "nyc --reporter=html mocha src/**/*.spec.ts src/*.spec.ts --require ts-node/register",
    "build": "tsc",
    "start_A": "tsc && node dist/A.js"
  },

But the changes I made to A.ts don't take any effect, the output is the same and A.js file matches the one before any edits... why is that? I tried to delete dist/A.js file but same problem.

Algo
  • 21
  • 6
  • You have to pass `-w` option to tsc to watch files or rebuild after every change. By default it wont rebuild on its own. Also note that it wont delete any files in `dist` so there may be files leftover from last build. – Code Spirit Nov 16 '21 at 20:06
  • @CodeSpirit so this: ""start_A": "tsc && node dist/A.js"" should change to this: ""start_A": "tsc -w && node dist/A.js""? – Algo Nov 16 '21 at 20:09
  • Not exactly because node will still be only run once and only load the script once. You need something like ts-node and nodemon but there are also many guides explaining this so I wont mention it here but maybe take a look here: https://stackoverflow.com/questions/38276862/is-there-a-way-to-use-npm-scripts-to-run-tsc-watch-nodemon-watch – Code Spirit Nov 16 '21 at 20:15
  • But I deleted all .js leftovers where the old versions came from... – Algo Nov 16 '21 at 20:17
  • Have you exited and restarted nodejs server? Without source I also cant exclude that it just produces same output. – Code Spirit Nov 16 '21 at 20:18
  • @CodeSpirit how to do that? sorry I'm totally new – Algo Nov 16 '21 at 20:21
  • Please watch any of the thousands of nodejs beginner tutorials out there. – Code Spirit Nov 16 '21 at 20:23
  • I didn't find one for my problem – Algo Nov 16 '21 at 20:24
  • Update, I exited visual code and it worked! any other way to do that without exiting everytime? – Algo Nov 16 '21 at 20:25
  • Please provide enough code so others can better understand or reproduce the problem. – Community Nov 18 '21 at 11:03

0 Answers0