Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Node.js I need a single script to combine tsc build watch with nodemon

I currently have two scripts:

"scripts": {
    "build": "tsc -p . -w",
    "watchjs": "nodemon dist/index.js"
}

And I need two terminals one for build one for watchjs, I want to combine these two scripts into a single script so that it automatically builds after changes have been detected and runs it after build!

I tried something like:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

"start": "tsc -p . -w && node dist/index.js",

But obviously

tsc -w

Never ends therefore I cannot call a command directly after a build has been completed!

>Solution :

suppose your system is Windows (for below solution you need concurrently package as a devDependency)

    "serve": "concurrently \"tsc -w\" \"nodemon dist/index.js\""

good luck !

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading