如何修复此 npm start 不起作用(在 npx create-react-app 之后)

IT技术 node.js reactjs npm command
2021-05-21 13:22:54
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todos-clone-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todos-clone-app@0.1.0 start 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!     /home/josh/.npm/_logs/2020-08-21T19_28_35_521Z-debug.log

编辑:

包.json

{
  "name": "todos-clone-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.3",
    "webpack-dev-server": "^3.11.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [ ">0.2%", "not dead", "not op_mini all" ],
    "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ]
  }
}
3个回答

尝试删除您的node_modules目录和package-lock.json文件。然后运行npm install

就我而言,这是因为不在正确的文件夹中。

通常,我创建一个文件夹并转到 Vs 代码将其打开create-react-app "folder name"以在控制台中输入

问题是我试图npm start在父文件夹而不是“文件夹名称”中。

您所要做的就是:

  1. cd folder_name
  2. npm start

尝试:

npx create-react-app ./

它对我有用。