Search code examples
npmnpm-scriptsnpx

How can I run other commands on top of nodemon


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?


Solution

  • && 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