Create-React-App:在本地计算机上部署时出现 ESlint 错误

2024-03-27

我正在使用 create-react-app (React v16.12.0)。当我运行时出现以下错误'npm start'在苹果电脑上。

[1] There might be a problem with the project dependency tree.
[1] It is likely not a bug in Create React App, but something you need to fix locally.
[1]
[1] The react-scripts package provided by Create React App requires a dependency:
[1]
[1]   "eslint": "^6.6.0"
[1]
[1] Don't try to install it manually: your package manager does it automatically.
[1] However, a different version of eslint was detected higher up in the tree:
[1]
[1]   /Users/abz/node_modules/eslint (version: 6.5.1)
[1]
[1] Manually installing incompatible versions is known to cause hard-to-debug issues.
[1]
[1] If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
[1] That will permanently disable this message but you might encounter other issues.
[1]
[1] To fix the dependency tree, try following the steps below in the exact order:
[1]
[1]   1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
[1]   2. Delete node_modules in your project folder.
[1]   3. Remove "eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
[1]   4. Run npm install or yarn, depending on the package manager you use.
[1]
[1] In most cases, this should be enough to fix the problem.
[1] If this has not helped, there are a few other things you can try:
[1]
[1]   5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
[1]      This may help because npm has known issues with package hoisting which may get resolved in future versions.
[1]
[1]   6. Check if /Users/abz/node_modules/eslint is outside your project directory.
[1]      For example, you might have accidentally installed something in your home folder.
[1]
[1]   7. Try running npm ls eslint in your project folder.
[1]      This will tell you which other package (apart from the expected react-scripts) installed eslint.
[1]
[1] If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
[1] That would permanently disable this preflight check in case you want to proceed anyway.
[1]
[1] P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
[1]
[1] react-scripts start exited with code 1

我用谷歌搜索发现

  1. 以下许多人建议的解决方案

    • 删除eslint and babel-eslint from users/abz/node_modules/文件夹
    • Delete package.json-lock, node_modules来自本地项目
    • Run npm install and npm start

    我尝试过,但这个解决方案对我不起作用。

  2. 这个问题可以通过使用来缓解

    adding an `.env file` in root folder with statement `SKIP_PREFLIGHT_CHECK=true` 
    

    但是,这并不是这个问题的解决方案。

有什么帮助吗?


发生这种情况是因为在父级别安装了具有不同版本的依赖项。在你的情况下是/Users/abz/node_modules/eslint。只需从 root 运行此命令

rm -rf node_modules/eslint

这应该可以解决你的问题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Create-React-App:在本地计算机上部署时出现 ESlint 错误 的相关文章

  • Nextjs 无法在生产环境中的“.next”目录中找到有效的构建

    我正在 docker 中运行我的应用程序 但我的生产构建和启动脚本仅在 docker 环境中失败 虽然node env开发在docker环境下运行良好 这是我的脚本 无法进行生产构建并启动服务器 我正在使用nodemon和babel bui
  • 渲染作为 Prop 传入的 Component

    我怎样才能渲染一个StyledComponent它是作为道具传入的吗 我正在传递一个Spinner组件到我的BarComponent作为渲染的道具 我尝试使用 this props icon in my BarComponent在下面的示例
  • 如何在 Gradle 构建脚本中使用 java 库?

    我需要在 Gradle 脚本中使用 Apache Commons 那么我需要在哪里添加依赖项以使其可用 我的 Android 项目中不需要它 但只在 gradle 脚本中需要 您需要添加依赖项buildscript部分如下 buildscr
  • 刷新或直接点击链接时找不到 React.js 页面

    我在此链接上有一个反应项目 https notchy cross 000webhostapp com https notchy cross 000webhostapp com 如果向下滚动 您会看到一个名为 产品类别 的部分 https i
  • ReactTransitionGroup 不适用于 React-redux 连接组件

    我正在开发一个更大的项目 但我创建了这个简短的示例来说明问题 如果我使用Box组件 它的工作原理 它在控制台中输出componentWillEnter and componentWillLeave当我们点击按钮时 如果我使用BoxConta
  • React autoFocus 将光标设置为输入值的开头

    我有一个受控输入 最初显示一个值 我已将该输入设置为自动聚焦 但当我希望它出现在末尾时 光标出现在输入的开头 我知道这可能是因为自动对焦是在值之前添加的 但我不能 100 确定 在输入字段末尾完成光标初始化的最佳方法是什么 var Test
  • 如何删除原生选项卡的边框

    我需要删除图像中标记的边框 我正在使用react native 和native base 选项卡 我需要删除选项卡的底部边框
  • 卸载 React 时删除事件监听器

    我有更高阶的组件 反应如下 export default function InnerComponent class InfiniteScrolling extends React Component constructor props s
  • 如何在react-bootstrap中禁用表单提交的

    在下面的代码片段中 我有许多文本类型的输入表单 如果用户点击 我似乎会得到相同的合成事件 就像他们按下提交按钮一样 我想忽略作为表单提交 只允许一个人按下 提交 按钮 我删除了一些表单组以减少示例 在所有情况下 按钮或 ENTER 键 e
  • React onClick 事件仅在渲染组件时触发

    动态渲染组件的 onClick 函数应通过 useState 设置所选日期 imgs 上的 onClicks 完全按照您的预期工作 没有任何问题 即使只是在其位置放置一个带有 onClick 属性的 div 也是行不通的 当组件渲染时 on
  • 如何渲染变量(或 prop)内部的 jsx/html?

    const Footer gt let a b Hey b return div Some bold text a div 这只会呈现为Some bold text b Hey b 如何将粗体文本渲染为粗体 变量内容是我自己的 所以我不必担
  • 如何将 SPA 嵌入 ASP.NET Core 库并从路径提供服务

    Szenario 我想构建一个 aspnetcore 库 模块includes一个小的SPA前端 IE html js css 文件应与 dll 一起提供 SPA 应从特定路径提供服务 即 some module does not需要可配置
  • IE 中未定义“代理”

    我通过 React Node 构建了一个 Excel 插件Umi https umijs org 我们已经实施了我们的身份验证系统 身份验证在 Chrome 和 Safari 中有效 我刚刚意识到它在 IE11 中不能很好地工作 F12表明
  • React - 按下按钮,继续调用函数

    我正在尝试实现缩放功能 onClick 工作正常 但我希望当我按住缩放按钮时它会连续缩放 我如何用 ReactJS 来实现这个 Jquery mousedown效果 按住左键时 https stackoverflow com questio
  • ESLint Airbnb ES6 和 Redux 异步操作围绕箭头主体的意外块语句

    我究竟做错了什么 我有其他三个异步操作也有同样的问题并且无法修复它 当你看一眼箭头函数文档 https developer mozilla org en docs Web JavaScript Reference Functions Arr
  • 在复选框内映射复选框 ReactJS

    我有一个函数 一旦主复选框被选中 就会触发子复选框 并且所有这些复选框都是从 JSON 映射的 主复选框 最高级别 及其下面的所有子复选框 第二级别 都会在单击时显示 并且效果很好 我想要显示的是单击时主复选框 第三级别 的子复选框2 级项
  • SWC with JavaScript:如何处理 CSS 导入以及如何绝对导入?

    TL DR 如何告诉 SWC 编译 React 组件中导入的 CSS 文件 如何告诉 SWC 在测试和 React 组件中编译绝对导入 这是一个最小的可重现示例 https github com janhesters riteway swc
  • 可以明确声明包依赖项的版本吗?

    我倾向于对我编写的代码进行明确而不是隐含的描述 因此 在成功创建自己的包之后 我立即想到的下一件事是如何最好地确保代码的健壮性和可靠性 其中一部分与我的包所依赖的包有关 实际问题 在这方面 是否可以明确声明需要 期望哪个版本的包依赖项 我正
  • 具有多种布局的 React Router v4

    我想在我的公共布局中渲染一些路线 并在我的私人布局中渲染一些其他路线 有没有一种干净的方法可以做到这一点 显然不起作用的示例 但我希望大致解释我正在寻找的内容
  • 为什么使用 getDerivedStateFromProps 而不是 componentDidUpdate?

    正如读到的这个 React Github 问题 https github com facebook react issues 12310我看到越来越多的 的代价render 相对较小 在 React 16 3 中 我想知道为什么要使用新的

随机推荐