How to watch ts,js,graphql extensions in ts-node-dev?

How to watch ts,js,graphql extensions in ts-node-dev?


0

I am trying to run the node server by ts-node-dev and restart on any any changes in specific files. It is restarting on any changes made to ts,js files however, it is not restarting on changes to graphql files. Any suggestions?

  "scripts": {
    "start": "tsnd --transpile-only --rs ./src/microservices/index.ts --watch--extionsions 
 ts,js,graphql"
  }

2

  • 1

    Hi, i think there's a typo in --watch--extionsions. But there's no –watch-extensions flag in ts-node-dev. You can give to the --watch flag the path where it needs to look at, i.e. : ...--watch .env, ../common/src, ../gql, .....

    – MatteoPHRE

    Jan 17, 2022 at 11:36


  • ts-node-dev can have the same flags as ts-node

    – Hazem Alabiad

    Jan 18, 2022 at 8:53

1 Answer
1


0

The syntax for –watch is different than nodemon and others that allow just a list of extensions. Here is more regex matching.

I also noticed you do not need to include the standard files it already watches. Based on the github issue where I found the solution you need to put –watch before the final entry point

In order to watch for .graphql files you need to add

--watch ./**/*.graphql

So your example should be:

"scripts": {
    "start": "tsnd --transpile-only --rs --watch ./**/*.graphql ./src/microservices/index.ts"
  }



Leave a Reply

Your email address will not be published. Required fields are marked *