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

1

7

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 :)

Upend answered 30/4, 2020 at 13:18 Comment(1)
I have tried && in this line also but not works... tsc --watch & nodemon dist/index.jsUpend
I
9

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!

Ingratiate answered 30/4, 2020 at 13:24 Comment(7)
@jimit_jd Okay, update your question to reflect that. Also add to your question what platform you are attempting to execute this command on.Ingratiate
If i run this project in ubuntu it works fine but not in windowsUpend
@jimit_jd I've updated the question to show one approach using a library for both windows and other platforms.Ingratiate
Hey Alexander , It works after using concurrently , Thank you so much for your helpUpend
But why it is not running normally in Windows as run in Ubuntu ??Upend
It's processed differently on windows just like it wouldn't work if you tried to set an environment variable in the command like ENV=dev or something it wouldn't work on windows.Ingratiate
Okay I see , and once again Thank you Alexander :)Upend

© 2022 - 2024 — McMap. All rights reserved.