Is there a way to use npm scripts to run tsc -watc

2020-02-16 07:36发布

I'm looking for a way to use npm scripts to run tsc --watch && nodemon --watch at the same time. I can run this commands independently, but when I want run both of them, only the first one is executed. eg. if I have this script:

"scripts": {    
    "runDeb": "set NODE_ENV=development&& tsc --watch && nodemon --watch"
  }

tsc --watch is executed but nodemon is never called, and vice versa.

7条回答
Anthone
2楼-- · 2020-02-16 08:39

I have been using AlterX's solution for a while now and it has worked perfectly, but I have found it to be rather slow. Instead, I am now using tsc-watch. It makes tsc use incremental compilation similar to the -w flag, making the restart of the application much faster.

It's as easy as putting something similar to this in your package.json:

"scripts": {
  "start": "./node_modules/.bin/tsc-watch --onSuccess \"node .\""
}
查看更多
登录 后发表回答