почему «: сервер» и «: клиент» не найдены? - PullRequest
0 голосов
/ 27 марта 2020

Я пытаюсь получить данные из базы данных. json.

вот мой файл базы данных. json:

{
    "posts": [
      { "id": "react-hooks", "title": "React Hooks", "content": "The greatest thing since sliced bread!", "author": "ali" },
      { "id": "react-fragments", "title": "Using React Fragments", "content": "Keeping the DOM tree clean!", "author": "ali" }
    ],
    "users": [
      { "id": 1, "username": "ali", "password": "********" }
    ],
    "themes": [
        { "id": 1, "primaryColor": "deepskyblue", "secondaryColor": "coral" },
        { "id": 2, "primaryColor": "orchid", "secondaryColor": "mediumseagreen" },
        { "id": 3, "primaryColor": "darkslategray", "secondaryColor": "slategray" }
    ]
  }

после этого я выполнил > npm install --save json -server и > npx json -server --watch server / db. json, и я отредактировал "сценарии ": расстаться следующим образом:

"start:server": "npx json-server --watch server/db.json",
"start:client": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"

тогда я извинился > npm install - сохранить одновременно и затем я добавил эту строку в " scripts ":

"start": "npx concurrently \"npm run start:server\" \"npm run start:client\"",

, затем я выполнил > npm install - сохранить http-proxy-middleware и после этого создал setupProxy. js и введите следующий код:

const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports=function(app){
    app.use(createProxyMiddleware('/api',{
        target:'http://localhost:5000',
        pathRewrite:{'^/api':''}
    }))
}

, затем я извиняюсь npm install и после этого при запуске npm start выдает следующую ошибку:

The system cannot find the file :client.
[5] start:client exited with code 1
[2] The system cannot find the file :server.
[2] start:server exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reacttutorial@0.1.0 start: `npx concurrently "npm run start:server" "npm run start:client"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reacttutorial@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

, и есть два windows оповещения о том, что «: server» и «: client» не могут быть найдены.

Я создал совершенно новое приложение, выполнив npx create-реагировать-app responsetutorial . у меня просто заканчиваются идеи. Может ли кто-нибудь помочь мне в этом, пожалуйста?

...