gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 13:47:38 29 4
gpt4 key购买 nike

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

[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

我用谷歌搜索并发现
  • 遵循许多人建议的解决方案
  • 删除 eslint and babel-eslint来自 users/abz/node_modules/文件夹
  • 删除 package.json-lock, node_modules来自本地项目
  • 运行 npm installnpm start

  • 我试过了,这个解决方案对我不起作用。
  • 这个问题可以通过使用来缓解
    adding an `.env file` in root folder with statement `SKIP_PREFLIGHT_CHECK=true` 

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

  • 有什么帮助吗?

    最佳答案

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

    rm -rf node_modules/eslint

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

    关于reactjs - Create-React-App:在本地机器上部署时出现 ESlint 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60124662/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com