简体   繁体   中英

NPM error when trying to launch react and nodejs

I have a nodejs and reactjs project. I have writen server and it's working by its own and writen a react SPA and its working too by its own. I uses "concurently" for starting them together but then get these errors:

[0] npm ERR! missing script: servernpm run client
[0]
[0] npm ERR! A complete log of this run can be found in:
[0] npm ERR!     C:\Users\1\AppData\Roaming\npm-cache\_logs\2020-12-14T18_43_22_867Z-debug.log
[0] npm run server"npm run client exited with code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! shop@1.0.0 dev: `concurrently "npm run server""npm run client"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the shop@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\1\AppData\Roaming\npm-cache\_logs\2020-12-14T18_43_22_906Z-debug.log

I have deleted node_modules in client dir and install it agin but it did help me Here is my main package.json

{
  "name": "shop",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "node app.js",
    "server": "nodemon app.js",
    "client": "npm run start --prefix client",
    "dev": "concurrently \"npm run server\"\"npm run client\""
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "config": "^3.3.3",
    "express": "^4.17.1",
    "express-validator": "^6.8.0",
    "jsonwebtoken": "^8.5.1",
    "mongoose": "^5.11.7"
  },
  "devDependencies": {
    "concurrently": "^5.3.0",
    "nodemon": "^2.0.6"
  }
}

here is my client package.json(react)

 {

  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.6",
    "@testing-library/react": "^11.2.2",
    "@testing-library/user-event": "^12.6.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.1",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Can you help me? I would appriciate that!

Your script is not written correctly, it "glues" lines together and you get this: servernpm run client. Change it to:

"dev": "concurrently \"npm run server\" \"npm run client\""

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM