Home > OS >  How can I run other commands on top of nodemon
How can I run other commands on top of nodemon

Time:08-19

I was just woundering if it possible to run other commands along side nodemon package?

What I am trying to achieve here?

In package.json: I have two scripts nodemon and npx for tailwind css

{
  "name": "project-name",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "dependencies": {
    "nodemon": "^2.0.19",
    "tailwindcss": "^3.1.8"
  },
  "devDependencies": {},
  "scripts": {
    "start": "node main.js",
    "dev": "nodemon main.js && npx tailwindcss -i ./input.css -o ./output.css --watch"
  },
  "author": "",
  "license": "ISC",
 }

I'm trying to run both packages at the same time so I tried to add the && btween the first and the second command but that didn't work, because both nodemon and tailwind css keep listing for file changes without exiting.

I'm trying to make them both some how run at the same same time.

is that possible?

CodePudding user response:

You can use a package called concurrently.

npm i concurrently --save-dev

and then your script should look like this:

"dev": "concurrently \"nodemon main.js\" \"npx tailwindcss -i ./input.css -o ./output.css --watch\" "

You can find more details in the link below

How can I run multiple npm scripts in parallel?

CodePudding user response:

&& only runs commands after each other. Not concurrently

You can use a package like concurrently to run them in parallel.

"dev": "concurrently \"nodemon main.js\" \"npx tailwindcss -i ./input.css -o ./output.css --watch\"

There are also alternatives to concurrently

  • Related