简体   繁体   English

“babel-eslint”不能让我安装反应

[英]"babel-eslint" can't let me install react

I am setting up a new react App, having installed it, i then added a name to the react app i begin to have a babel-eslint issue我正在设置一个新的 react 应用程序,安装了它,然后我为 react 应用程序添加了一个名称,我开始遇到babel-eslint问题

portfolio@0.1.0 start C:\\Users\\Samson Adedayo\\Desktop\\portfolio投资组合@0.1.0 开始 C:\\Users\\Samson Adedayo\\Desktop\\portfolio
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.这可能不是 Create React App 中的错误,而是您需要在本地修复的问题。

The react-scripts package provided by Create React App requires a dependency: Create React App 提供的 react-scripts 包需要一个依赖:

"babel-eslint": "10.0.2" "babel-eslint": "10.0.2"

Don't try to install it manually: your package manager does it automatically.不要尝试手动安装:您的包管理器会自动安装。 However, a different version of babel-eslint was detected higher up in the tree:但是,在树的更高位置检测到了不同版本的 babel-eslint:

C:\\Users\\Samson Adedayo\\Desktop\\node_modules\\babel-eslint (version: 10.0.1) C:\\Users\\Samson Adedayo\\Desktop\\node_modules\\babel-eslint(版本:10.0.1)

Manually installing incompatible versions is known to cause hard-to-debug issues.众所周知,手动安装不兼容的版本会导致难以调试的问题。

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.如果您希望忽略此检查,请将 SKIP_PREFLIGHT_CHECK=true 添加到项目中的 .env 文件中。 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.删除项目文件夹中的 package-lock.json(不是 package.json!)和/或 yarn.lock。
  2. Delete node_modules in your project folder.删除项目文件夹中的 node_modules。
  3. Remove "babel-eslint" from dependencies and/or devDependencies in the package.json file in your project folder.从项目文件夹中的 package.json 文件中的依赖项和/或 devDependencies 中删除“babel-eslint”。
  4. Run npm install or yarn, depending on the package manager you use.运行 npm install 或 yarn,具体取决于您使用的包管理器。

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:如果这没有帮助,您还可以尝试其他一些方法:

  1. If you used npm, install yarn ( http://yarnpkg.com/ ) and repeat the above steps with it instead.如果您使用 npm,请安装 yarn ( http://yarnpkg.com/ ) 并用它重复上述步骤。 This may help because npm has known issues with package hoisting which may get resolved in future versions.这可能会有所帮助,因为 npm 存在已知的包提升问题,这些问题可能会在未来版本中得到解决。

  2. Check if C:\\Users\\Samson Adedayo\\Desktop\\node_modules\\babel-eslint is outside your project directory.检查 C:\\Users\\Samson Adedayo\\Desktop\\node_modules\\babel-eslint 是否在您的项目目录之外。 For example, you might have accidentally installed something in your home folder.例如,您可能不小心在主文件夹中安装了某些东西。

  3. Try running npm ls babel-eslint in your project folder.尝试在您的项目文件夹中运行 npm ls babel-eslint。 This will tell you which other package (apart from the expected react-scripts) installed babel-eslint.这将告诉您安装了 babel-eslint 的其他软件包(除了预期的 react-scripts)。

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.如果没有其他帮助,请将 SKIP_PREFLIGHT_CHECK=true 添加到项目中的 .env 文件中。 That would permanently disable this preflight check in case you want to proceed anyway.如果您无论如何都想继续,这将永久禁用此预检检查。

PS We know this message is long but please read the steps above :-) We hope you find them helpful! PS 我们知道这条消息很长,但请阅读上面的步骤 :-) 我们希望它们对您有所帮助!

npm ERR! npm 错误! code ELIFECYCLE npm ERR!代码 ELIFECYCLE npm ERR! errno 1 npm ERR!错误号 1 npm 错误号! portfolio@0.1.0 start: react-scripts start npm ERR!投资组合@0.1.0 开始: react-scripts start npm ERR! Exit status 1 npm ERR!退出状态 1 npm ERR! npm ERR! npm 错误! Failed at the portfolio@0.1.0 start script.在portfolio@0.1.0 启动脚本失败。 npm ERR! npm 错误! This is probably not a problem with npm.这可能不是 npm 的问题。 There is likely additional logging output above.上面可能有额外的日志输出。

npm ERR! npm 错误! A complete log of this run can be found in: npm ERR!可以在以下位置找到此运行的完整日志:npm ERR! C:\\Users\\Samson Adedayo\\AppData\\Roaming\\npm-cache_logs\\2019-09-11T18_30_41_153Z-debug.log C:\\Users\\Samson Adedayo\\AppData\\Roaming\\npm-cache_logs\\2019-09-11T18_30_41_153Z-debug.log

I was having this same issue.我遇到了同样的问题。 Occasionally the create-react-app does not install its dependencies correctly.有时 create-react-app 没有正确安装它的依赖项。 To solve this I did the following:为了解决这个问题,我做了以下事情:

  • delete the node modules folder删除节点模块文件夹
  • delete package-lock.json (NOT PACKAGE.JSON)删除 package-lock.json (NOT PACKAGE.JSON)
  • manually add the babel-eslint to your package.json手动将 babel-eslint 添加到 package.json
  • To do this add "babel-eslint": "10.0.2" to the end of your dependencies list为此,将"babel-eslint": "10.0.2"到依赖项列表的末尾

    • finally, run npm i and you should be good to go最后,运行npm i就可以了

Create .env file in your react-app folder and paste below line in it在您的 react-app 文件夹中创建.env文件并在其中粘贴以下行

SKIP_PREFLIGHT_CHECK=true

your problem will get solve你的问题会得到解决

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM