我所做的就是运行create react应用程序,并在应用程序中刻录cd,然后try 运行npm/yarn start.我得到以下错误/输出/日志(log).我已经完成了所有建议的步骤.唯一有效的方法是在我的系统中使用SKIP_PREFLIGHT_CHECK=true.env是双方的最后手段

Last login: Tue Oct 30 16:30:24 on ttys002
TheLAB11:~ jasonspiller$ cd repos/react-express-graphql-app/
TheLAB11:react-express-graphql-app jasonspiller$ npm start

> react-express-graphql-app@0.1.0 start /Users/jasonspiller/repos/react-express-graphql-app
> react-scripts start


There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-jest": "23.6.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-jest was detected higher up in the tree:

  /Users/jasonspiller/node_modules/babel-jest (version: 23.4.2) 

Manually installing incompatible versions is known to cause hard-to-debug issues.

If prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if /Users/jasonspiller/node_modules/babel-jest is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls babel-jest in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed babel-jest.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-express-graphql-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the react-express-graphql-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!     /Users/jasonspiller/.npm/_logs/2018-10-30T23_09_42_358Z-debug.log

推荐答案

我也有同样的问题.由于某种原因,该软件包最终出现在我的主目录中的一个node_modules目录中.它也给了我同样的错误.

我不确定如何解决这个问题,因为npm uninstall -g babel-jestyarn global remove babel-jest什么都不做.

我通过清理导致问题的文件夹来修复它:

知道这些包最终是如何到达那里的,以及如何正确地处理它们,这将是一件非常棒的事情,但是现在,仅仅删除文件夹就足以让CRA dev服务器运行,而不会跳过飞行前判断.

Reactjs相关问答推荐

如何使用next.js以DOM为目标在映射中使用Ref

react 副作用循环

有没有办法让两个状态在两次精准渲染中更新?

在构建或部署Reaction应用程序时出错

console.logs 没有显示在浏览器控制台上,但显示在我的终端上

将 useRef 与 useImperativeHandle 一起使用时,React 不会重新渲染

获取 不能显示为 的后代.错误,但不太确定如何构建我的代码以避免此警告

Chakra UI:如何在选中状态下设置复选框 colored颜色

如何在我的自定义主题中样式化MUI TreeItem组件

根据其中的值不同地react setState 更新状态

在 React 中使用复选框管理状态

将 useState 设置为组件内部的值

@react-three/postprocessing 没有匹配的从 three.module.js 导出以导入WebGLMultisampleRenderTarget

docker:来 automorphic 护进程的错误响应:未指定命令.的原因是什么?

如何使用 React 在客户端获取 nestjs websocket 异常错误?

使用 Jest/React 测试库时,如何测试由 setInterval 函数创建的 DOM 更改?

React JS:如何判断用户使用的是浏览器 url 还是桌面 electron

如何在 Cypress E2E 的站点上测试react 组件?

试图将页面限制为仅登录但有条件的用户似乎永远不会运行

由于另一个子组件,如何在react 中渲染另一个子组件