【问题标题】:Getting error on npm start create-react-app在 npm start create-react-app 上出现错误
【发布时间】:2019-05-07 08:32:18
【问题描述】:

我目前正在学习 React。我已经完成了:

  • npm i -g create-react-app(成功)
  • create-react-app react-app(成功)
  • cd react-app
  • npm start(以上错误)

输出:

  • npm start \Git\cmd 出乎意料。此时。

  • npm 错误!代码 ELIFECYCLE

所以,我通过在线搜索尝试了什么:

  • npm cache clean --force
  • 删除节点模块
  • 删除 package-lock.json
  • npm run clear
  • npm 安装

没有解决。我已经读过我不应该全局安装但现在它已经安装(?)我可以回滚吗?我无法再次运行 npm i g create-react-app 。 谢谢

编辑:添加截图 https://i.ibb.co/mNKLskX/Capturar.png

【问题讨论】:

  • 请发布您的 package.json 内容
  • 另外,您使用的是什么操作系统?如果您在 Linux 上,可能是权限问题
  • { "name": "react-app", "version": "0.1.0", "private": true, "dependencies": { "react": "^16.6.3", "react-dom": "^16.6.3", "react-scripts": "2.1.1" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": "react-app" }, "browserslist": [ ">0.2%", "not dead", "not ie <= 11", "not op_mini all" ] }
  • 我使用的是 Windows
  • 我添加了截图

标签: node.js reactjs npm


【解决方案1】:

用 npm 试试init

npm init react-app my-app

或者,试试npx

npx create-react-app my-app

cd my-app

npm start

【讨论】:

  • 它安装一切正常,但 npm start 仍然给出同样的错误
  • 尝试删除 node-module 目录、package-lock.json 并清除缓存然后重试。
【解决方案2】:

您是否尝试按照“create-react-app”中的步骤进行操作?

`要创建一个新的应用程序,您可以选择以下方法之一:

npx

 npx create-react-app my-app

(npx 随附于 npm 5.2+ 及更高版本,请参阅旧 npm 版本的说明)

npm

npm init react-app my-app

npm init 在 npm 6+ 中可用

纱线

yarn create react-app my-app

yarn create 在 Yarn 0.25+ 中可用`

欲了解更多信息:https://github.com/facebook/create-react-app

【讨论】:

  • 是的,它安装得很好。错误出现在 npm start
猜你喜欢
  • 2017-02-18
  • 2020-11-17
  • 1970-01-01
  • 2019-05-23
  • 2020-11-04
  • 2020-07-11
  • 1970-01-01
  • 2019-06-11
  • 2021-02-27
相关资源
最近更新 更多