trying to run react and node.js concurrently

869 views Asked by At

package.json

      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "dev": "cd profile-app-server && nodemon server.js",
        "client": "cd client/profile-front-end && npm start",
        "start": "concurrently \"npm run dev\" \"npm run client\" "
      },

npm ERR! enoent ENOENT: no such file or directory, open '/Users/SebastianRusso/Desktop/profile-app/package.json'

when i run them separately, they both work fine. the server is running on 3001, so not to interfere with react.

the app is called, 'profile-app' which holds a 'client folder' which holds, 'profile-front-end' the app, 'profile-app' also holds 'profile-app-server'

i'm wondering if i have the paths mixed up somehow. I've played around and tried different things, but kind of at a road block now

2

There are 2 answers

2
Noah Kanyo On

My guess is you need to figure out the path to get from your server package.json to your client package.json file. The client path for your script may need to be slightly altered.

"scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "dev": "cd profile-app-server && nodemon server.js",
        "client": "cd ../client/profile-front-end && npm start",
        "start": "concurrently \"npm run dev\" \"npm run client\" "
      },

Not sure if that's the correct path, but it is probably somewhere along those lines.

0
Seb On

so basically to make both run, only the client can be in another folder.

i put the server in a separate folder as well, but that was incorrect, and that's why npm start could not find the folder.

in the end i removed the server folder, and changed the code to this and it works (runs both client side and server side)

      "dev": "nodemon server.js",
      "client": "cd client/avybe-challenge-profile && npm start",
      "start": "concurrently \"npm run dev\" \"npm run client\" "