jas*_*ler 12 macos npm reactjs react-scripts yarnpkg
我正在做的就是运行create-react-app和cd'ing到应用程序,然后尝试运行npm/yarn start.我得到以下错误/输出/日志.我已经完成了所有建议的步骤.唯一有效的是我的.env中的SKIP_PREFLIGHT_CHECK = true作为Yarn和npm的最后手段.我最近更新到Mojave,如果人们有类似的经历,我不得不重新安装我的Xcode.
如果图像不够,我粘贴下面的输出.
非常感谢你提前帮助...杰森
控制台截图 
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
Run Code Online (Sandbox Code Playgroud)
Wad*_*e J 15
我刚遇到同样的问题.由于某种原因,包最终出现node_modules在我的主目录中的目录中.它还给了我与jest包完全相同的错误.
我不知道的正确解决这一问题的办法npm uninstall -g babel-jest,并yarn global remove babel-jest没有做任何事情.
我通过吹掉导致问题的文件夹来修复它:
bash
rm -rf ~/node_modules/babel-jest ~/node_modules/jest
很高兴知道这些软件包是如何结束的,以及摆脱它们的正确方法,但是现在只需删除文件夹就足以让CRA dev服务器运行而不会跳过预检检查.
Raj*_*esh 14
我也遇到了类似的问题,并且能够按照以下步骤解决问题。
SKIP_PREFLIGHT_CHECK=真
保存文件
移除 node_modules、yarn.lock、package.lock
然后重新安装 node_modules
安装
这应该工作
Ahm*_*şek 13
如果在运行应用程序的文件夹的父目录中没有node_modules,则会出现此问题。我通过删除node_modules目录解决了这个问题。
Mar*_*ahl 11
该问题似乎已经在create-react-app 3.0.0中再次出现。
The react-scripts package provided by Create React App requires a dependency:
"babel-jest": "24.7.1"
Run Code Online (Sandbox Code Playgroud)
正如abisuq在https://github.com/facebook/create-react-app/issues/6756#issuecomment-489562571中 指出的那样,将版本解析添加到package.json中可以暂时解决此问题。
"resolutions": {
"babel-jest": "24.7.1"
},
Run Code Online (Sandbox Code Playgroud)
更新:它已在create-react-app 3.0.1中修复。如果可以选择升级,则可以运行
npm install --save --save-exact react-scripts@3.0.1
Run Code Online (Sandbox Code Playgroud)
要么
yarn add --exact react-scripts@3.0.1
Run Code Online (Sandbox Code Playgroud)
小智 5
已安装:babelk-jest@24.7.1 和 babel-jest@24.8.0
\n\n这意味着安装两个具有不同版本的 babel-jest
\n\n我遇到了这个问题,并最终轻松解决了它。你可能知道,当我们使用 create-react-app 时,Jest 是默认配置的,你不需要安装 Jest(当我们使用 Webpack 时,我们可以安装 Jest)。因此,如果您使用 Create-react-app 并错误地安装了 Jest:
npm install --save-dev jest),你可以直接从Package.json中删除jest或使用:(npm uninstall --save-dev jest)npm install现在您没有收到错误,您可以轻松使用: (npm start) 或 (npm test)
另外,值得一提的是,我在 React 组件中安装了以下工具来编写我的测试: ( npm install --save-dev enzyme enzyme-adapter-react-16 jest-enzyme) 并使用 jest 和酶编写了我的测试。然后我很容易地使用:(npm test)
祝你好运!
小智 5
好吧,我在尝试了一切之后终于找到了解决方案。这是最终起作用的:
| 归档时间: |
|
| 查看次数: |
7545 次 |
| 最近记录: |