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

问题描述 投票:0回答:4
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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

编辑:

package.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" ]
  }
}
node.js reactjs npm command
4个回答
3
投票

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

一般情况下,我会创建一个文件夹,然后转到 Vs code 将其打开,然后在控制台中输入

create-react-app "folder name"

问题是我试图在父文件夹中

npm start
而不是“文件夹名称”。

您所要做的就是:

  1. cd folder_name
  2. npm start

2
投票

尝试删除您的

node_modules
目录和
package-lock.json
文件。然后运行
npm install


0
投票

对于所有未来最新的 Nodejs 版本,您需要修改 package.json,如下所示,以便 Reactjs 在浏览器中运行,只有当您使用默认添加的启动脚本命令运行 npm start 时遇到问题 更新您的脚本命令如下:

“脚本”:{“开始”:“react-scripts启动--openssl-legacy-provider”,


-2
投票

尝试:

npx create-react-app ./

它对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.