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

阿布兹

我正在使用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

我用谷歌搜索发现

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

    • eslint and babel-eslintusers/abz/node_modules/文件夹中删除
    • package.json-lock, node_modules从本地项目中删除
    • 运行npm installnpm start

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

  2. 可以通过使用以下方法缓解此问题

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

    但是,这不是解决此问题的方法。

有什么帮助吗?

阿努沙(Anuj Shah)

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

rm -rf node_modules/eslint

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

npm create-react-app启动错误

在Nginx上部署Create-React-App

使用create-react-app部署github页面时的React-router问题

运行create-react-native-app测试时FSEvents错误

使用Create React App进行React样式

部署create-react-app时无法加载资源错误404

MPI_Dims_create在远程计算机上引发错误

create-react-app eslint错误“解析错误:'import'和'export'可能仅与'sourceType:module'一起出现”

部署create-react-app

执行create-react-app会出现错误

尝试启动create-react-app和安装react-dev-utils时出现NPM错误E404

Flask App在本地计算机上出现404错误

运行npm install create-react-app时出现错误404

在Google App Engine上部署create-react-app

在由create-react-app创建的环境中获取本地JSON文件时,JSON解析错误

我只是从github克隆了一个React应用到本地计算机,但是当我在其上运行npm start时,出现了以下错误:

使用gh-pages在github上部署create-react-app时出现问题

在create-react-app中EXTEND_ESLINT = true时,打字稿解析错误

React路由在本地计算机上有效,但在GitHub页面上无效

无法在Github Pages上部署新的create-react-app

无法链接计算机上本地存储的HTML / CSS / REACT中的图像

在本地计算机上部署Web服务工作,但在另一台计算机上抛出运行时错误

在TFS代理上而不在我的本地计算机上构建时出现编译错误

Heroku 部署错误 - 带有 Create-React-App 的节点

在create-react-app中安装react项目时出现npm错误

在 Heroku 上部署 create-react-app 的应用程序错误

在 OpenShift 上部署 Create React App:EACCES:权限被拒绝,打开“/home/node/app/.eslintcache”

执行 npx create-react-app 时出现以下错误

npx create-react-app 安装时显示错误