"concurrently" issue to run both frontend and backend

34 views Asked by At

This is package.json of frontend

{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "proxy": "http://localhost:5000",
  "dependencies": {
    "@fortawesome/fontawesome-free": "^6.5.1",
    "@fortawesome/free-solid-svg-icons": "^6.5.1",
    "@fortawesome/react-fontawesome": "^0.2.0",
    "@reduxjs/toolkit": "^2.0.1",
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^1.6.4",
    "bootstrap": "^5.3.1",
    "bootstrap-icons": "^1.11.3",
    "rc-banner-anim": "^2.4.5",
    "react": "^18.2.0",
    "react-alice-carousel": "^2.8.0",
    "react-bootstrap": "^2.8.0",
    "react-dom": "^18.2.0",
    "react-helmet-async": "^2.0.4",
    "react-icons": "^4.11.0",
    "react-quill": "^2.0.0",
    "react-redux": "^9.0.4",
    "react-router-bootstrap": "^0.26.2",
    "react-router-dom": "^6.15.0",
    "react-scripts": "5.0.1",
    "react-slick": "^0.30.1",
    "react-toastify": "^10.0.4",
    "slick-carousel": "^1.8.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

And this is package.json for root(backend server)

{
  "name": "smile",
  "version": "1.0.0",
  "description": "",
  "type": "module",
  "main": "server.js",
  "scripts": {
    "start": "node backend/server.js",
    "server": "nodemon backend/server.js",
    "client": "npm start --prefix frontend",
    "dev": "concurrently \"npm run server\" \"npm run client\"",
    "data:import": "node backend/seeder",
    "data:destroy": "node backend/seeder -d",
    "build": "npm install && npm install --prefix frontend && npm run build --prefix frontend"
  },
  "author": "",
  "license": "MIT",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "colors": "^1.4.0",
    "cookie-parser": "^1.4.6",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "googleapis": "^133.0.0",
    "jsonwebtoken": "^9.0.2",
    "mongoose": "^8.0.3",
    "multer": "^1.4.5-lts.1",
    "nodemailer": "^6.9.9"
  },
  "devDependencies": {
    "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
    "concurrently": "^8.2.2",
    "nodemon": "^3.0.2"
  }
}

But when I run this command: $ npm run dev

Result(Website is not running):

> [email protected] dev
> concurrently "npm run server" "npm run client"

[0] npm run server exited with code 1
[1] npm run client exited with code 1

But if I run these "npm run server" and "npm run client" on two different terminal from project's root directory, it works fine. Both backend and frontend are running well and so my website.

Why I face this issue when I use "concurrently"?

0

There are 0 answers