Search code examples
node.jsreactjsexpresspackage.jsonconcurrently

How do i use concurrently in the following folder structure


I am trying to use concurrently to run backend and frontend at the same time and i tried but it is giving me error for not using its script correctly.

I am using concurrently in the backend package.json

>backend
all the backend files and package.json file for node js
>frontend
all the frontend files and package.json file for react js

Scripts

"scripts": {
    "start": "nodemon server.js",
    "start-server": "npm start --prefix backend",
    "start-client": "npm start --prefix frontend",
    "dev": "concurrently \" npm run start-server\" \" npm run start-client\""
  },

npm run dev

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

[0] 
[0] > [email protected] start-server
[0] > npm start --prefix backend
[0]
[1] 
[1] > [email protected] start-client
[1] > npm start --prefix frontend
[1]
[0] npm ERR! code ENOENT
[0] npm ERR! syscall open
[0] npm ERR! path C:\Users\hp\Documents\React_Projects\react-mui-node\backend\backend/package.json
[0] npm ERR! errno -4058
[0] npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\hp\Documents\React_Projects\react-mui-node\backend\backend\package.json'
[0] npm ERR! enoent This is related to npm not being able to find a file.
[0] npm ERR! enoent
[0]
[0] npm ERR! A complete log of this run can be found in:       
[0] npm ERR!     C:\Users\hp\AppData\Local\npm-cache\_logs\2022-09-15T01_15_58_352Z-debug-0.log
[1] npm ERR! code ENOENT
[1] npm ERR! syscall open
[1] npm ERR! path C:\Users\hp\Documents\React_Projects\react-mui-node\backend\frontend/package.json
[1] npm ERR! errno -4058
[1] npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\hp\Documents\React_Projects\react-mui-node\backend\frontend\package.json'
[1] npm ERR! enoent This is related to npm not being able to find a file.
[1] npm ERR! enoent
[0]  npm run start-server exited with code 4294963238
[1]
[1] npm ERR! A complete log of this run can be found in:       
npm ERR!     C:\Users\hp\AppData\Local\npm-cache\_logs\2022-09-15T01_15_58_389Z-debug-0.log
[1]  npm run start-client exited with code 4294963238


Solution

  • It was just a directory issue, i thought that i was in the current directory but was not fixed the issue with this code

    
    "dev": "concurrently \"cd ../frontend && npm start\" \"cd ../backend && npm start\""