0
"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "backend" : "nodemon backend/server.js",
  "frontend" : "npm start -p frontend",
  "dev": "concurrently \"npm run backend \"\"npm run frontend \""
}

I want to run frontend and backend file in one terminal command. But is do not work properly. Backend is run fine but frontend not runing.


> blog-project@1.0.0 dev
> concurrently "npm run backend ""npm run frontend "

[0] 
[0] > blog-project@1.0.0 backend
[0] > nodemon backend/server.js npm run frontend
[0] 
[0] [nodemon] 2.0.20
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching path(s): *.*
[0] [nodemon] watching extensions: js,mjs,json
[0] [nodemon] starting `node backend/server.js "npm run frontend"`
[0] server in runnig, port $(PORT)```
devpolo
  • 2,487
  • 3
  • 12
  • 28
Shuvo Roy
  • 11
  • 2

1 Answers1

0

It seems you're forgetting to move into your frontend folder before running it's start script. I would also recommend using --kill-others-on-fail when joining processes so that both fail together if either of them fails. That way you're not left manually cleaning up.

If you're using a frontend folder, for example:

"concurrently --kill-others-on-fail \"npm run backend\" \"cd ./frontend && npm run start\"",

Notice the script into the frontend folder first before trying to start it:

cd ./frontend && npm run start

You also should not need the -p flag.

Wesley LeMahieu
  • 2,296
  • 1
  • 12
  • 8