1

I'm stuck with npm --prefix. I'm trying to prefix my frontend folder so I can run both the backend and frontend at the same time.

I keep getting an error with the wrong pathway: \backend\frontend/package.json.

Can anyone help me with that?

{
      "name": "backend",
      "version": "1.0.0",
      "description": "User Authentication APP - MERN stack",
      "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\""
      }
    }
jsbrcad
  • 33
  • 1
  • 7
  • this question might relate to your issue. https://stackoverflow.com/q/44467600 – wei May 22 '22 at 04:09
  • 2
    If you execute `npm start --prefix frontend` in the folder `\backend`, the relative prefix will cause npm to search the folder `\backend\frontend`. You can use an absolute path: `npm start --prefix \frontend`. – Heiko Theißen May 22 '22 at 06:49

1 Answers1

0

You can test this package.json

"scripts": {
  "server": "npm run watch --prefix server",
  "client": "npm start --prefix client",
  "watch": "npm run server & npm run client"
}

Then run npm run watch

Community
  • 1
  • 1