oneone
oneone

Reputation: 42

Can't start client and server together with concurrently

index.js: const port = process.env.PORT || 3000;

server package.json:

    "start": "node index.js",
    "server": "nodemon index.js",
    "client": "npm start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\""
  },

client package.json:

"proxy": "http://localhost:5000",

I am starting it with npm run dev

Any idea where the problem might be?

error:

Error: Cannot find module '.../index.js'

Upvotes: 0

Views: 1765

Answers (2)

Andrew Grini
Andrew Grini

Reputation: 72

as I have had application and server folders, the same problems appeared. And I resolved it by giving the path --> "application": "cd ../ && npm start --prefix application"

{
  "server": "nodemon server/app.js",
  "application": "cd ../ && npm start --prefix application",
  "dev": "concurrently \"npm run server\"  \"npm run application\" "
}

Upvotes: 0

Joao Polo
Joao Polo

Reputation: 2163

try to map the subpath of the client project:

{
    "start": "node index.js",
    "server": "nodemon index.js",
    "client": "cd client && npm start",
    "dev": "concurrently \"npm run server\" \"npm run client\""
},

Upvotes: 1

Related Questions