0

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

服务器包.json:

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

客户端包.json:

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

我开始npm run dev

知道问题可能出在哪里吗?

错误:

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

4

2 回答 2

1

尝试映射客户端项目的子路径:

{
    "start": "node index.js",
    "server": "nodemon index.js",
    "client": "cd client && npm start",
    "dev": "concurrently \"npm run server\" \"npm run client\""
},
于 2019-10-30T15:45:42.117 回答
0

因为我有应用程序服务器文件夹,所以出现了同样的问题。我通过给出路径解决了这个问题 --> "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\" "
}
于 2021-04-11T09:47:10.397 回答