How to run a nx script and nodemon script in one-line shell command?

51 Views Asked by At

My project is Angular. I have added a script line for running nx and nodemon commands inside of the package.json. The first command runs but the second one does not. If I stop the process and then the second command starts to run. My code is like that:

...
"scripts": {
    ...
    "translate": "nx run my-project:serve --port=1202 & nodemon apps/my-project/src/assets/i18n/translate/index.js"
}
...

I could give an extra information. My laptop OS is Windows. This script works in macOS.

1

There are 1 best solutions below

1
sdgluck On

You can use the concurrently package to run both commands simultaneously.

...
"scripts": {
    ...
    "translate": "concurrently \"nx run my-project:serve --port=1202\" \"nodemon apps/my-project/src/assets/i18n/translate/index.js\""
}
...