Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not run Nodemon in node project build with Typescript (In Windows)

Node project is built with Typescript and there are three script in package.json file but when I run it shows ...

If i run this project in ubuntu it works fine but not in windows

Image of output terminal

but after this nodemon is not start to run project.

Script in Package.json

"start": "tsc --watch & nodemon dist/index.js",
"lint": "tslint -c tslint.json 'src/**/*.ts' --fix",
"build": "tsc"

Help me to solve this, Thank you in advance :)

like image 646
Jimit Raval Avatar asked Apr 30 '20 13:04

Jimit Raval


People also ask

How do I run a TypeScript project with Nodemon?

In your package. json file, create a start script. This will serve as the command that will be run and restarted by nodemon when a file changes. This passes the start script as the executable command to run for your project by nodemon.

What to do if Nodemon is not working?

Use npx to solve the error "'nodemon' is not recognized as an internal or external command, operable program or batch file", e.g. npx nodemon server. js or install the package globally by running npm install -g nodemon and make sure your PATH environment variable is set up correctly.


1 Answers

You seem to be missing an & character between tsc --watch and nodemon dist/index.js. A single & is not a valid and operator:

"start": "tsc --watch && nodemon dist/index.js",

Update It looks like the issue is on Windows. Commonly this issue is solved by using a library such as concurrently or cross-env to execute commands in a similar way on Windows. After you've installed concurrently:

"start": "concurrently \"tsc --watch\" \"nodemon dist/index.js\"",

Hopefully that helps!

like image 89
Alexander Staroselsky Avatar answered Oct 16 '22 12:10

Alexander Staroselsky