简体   繁体   English

react-scripts babel 脚本在本地反应应用程序上使用纱线运行时出错

[英]react-scripts babel scripts error running with yarn on local react application

Facing this issue after running yarn, trying to run my repo, this is my repo structure运行yarn后遇到这个问题,尝试运行我的repo,这是我的repo结构

在此处输入图片说明

I run command yarn and this happens我运行命令纱线,这发生了

yarn yarn install v1.17.3 [1/4] Resolving packages... [2/4] Fetching packages... info fsevents@1.2.12: The platform "win32" is incompatible with this module. yarn yarn install v1.17.3 [1/4] 正在解析包... [2/4] 正在获取包... info fsevents@1.2.12: “win32”平台与此模块不兼容。 info "fsevents@1.2.12" is an optional dependency and failed compatibility check. info "fsevents@1.2.12" 是一个可选的依赖项并且兼容性检查失败。 Excluding it from installation.从安装中排除它。 info fsevents@2.0.7: The platform "win32" is incompatible with this module. info fsevents@2.0.7:平台“win32”与此模块不兼容。 info "fsevents@2.0.7" is an optional dependency and failed compatibility check. info "fsevents@2.0.7" 是一个可选的依赖项并且兼容性检查失败。 Excluding it from installation.从安装中排除它。 [3/4] Linking dependencies... warning "antd > rc-picker@1.1.5" has unmet peer dependency "dayjs@^1.8.18". [3/4] 正在链接依赖项...警告“antd > rc-picker@1.1.5”有未满足的对等依赖项“dayjs@^1.8.18”。 warning "react-scripts-rewired > @typescript-eslint/eslint-plugin@1.13.0" has incorrect peer dependency "eslint@^5.0.0".警告“react-scripts-rewired > @typescript-eslint/eslint-plugin@1.13.0”有不正确的对等依赖“eslint@^5.0.0”。 warning "react-scripts-rewired > @typescript-eslint/parser@1.13.0" has incorrect peer dependency "eslint@^5.0.0".警告“react-scripts-rewired > @typescript-eslint/parser@1.13.0”具有不正确的对等依赖关系“eslint@^5.0.0”。 warning "react-scripts-rewired > eslint-config-react-app@5.2.1" has incorrect peer dependency "@typescript-eslint/eslint-plugin@2.x".警告“react-scripts-rewired > eslint-config-react-app@5.2.1”有不正确的对等依赖“@typescript-eslint/eslint-plugin@2.x”。 warning "react-scripts-rewired > eslint-config-react-app@5.2.1" has incorrect peer dependency "@typescript-eslint/parser@2.x".警告“react-scripts-rewired > eslint-config-react-app@5.2.1”有不正确的对等依赖“@typescript-eslint/parser@2.x”。 warning "react-scripts-rewired > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".警告“react-scripts-rewired > @typescript-eslint/eslint-plugin > tsutils@3.17.1”有未满足的对等依赖“typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3。 0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta”。 warning " > eslint-config-airbnb@18.1.0" has unmet peer dependency "eslint@^5.16.0 || ^6.8.0".警告“> eslint-config-airbnb@18.1.0”有未满足的对等依赖“eslint@^5.16.0 || ^6.8.0”。 warning " > eslint-config-airbnb@18.1.0" has unmet peer dependency "eslint-plugin-react@^7.19.0".警告“> eslint-config-airbnb@18.1.0”有未满足的对等依赖“eslint-plugin-react@^7.19.0”。
warning " > eslint-config-airbnb@18.1.0" has unmet peer dependency "eslint-plugin-react-hooks@^2.5.0 || ^1.7.0".警告“> eslint-config-airbnb@18.1.0”有未满足的对等依赖“eslint-plugin-react-hooks@^2.5.0 || ^1.7.0”。 warning "eslint-config-airbnb > eslint-config-airbnb-base@14.1.0" has unmet peer dependency "eslint@^5.16.0 || ^6.8.0".警告“eslint-config-airbnb > eslint-config-airbnb-base@14.1.0”有未满足的对等依赖“eslint@^5.16.0 || ^6.8.0”。 warning " > eslint-plugin-import@2.20.1" has unmet peer dependency "eslint@2.x - 6.x".警告“> eslint-plugin-import@2.20.1”有未满足的对等依赖“eslint@2.x - 6.x”。 [4/4] Building fresh packages... success Saved lockfile. [4/4] 构建新包...成功已保存锁定文件。 Done in 166.99s.在 166.99 秒内完成。 PS D:\\Repos\\pth\\telehealth-frontend> yarn start yarn run v1.17.3 $ npm run build-css && react-scripts start PS D:\\Repos\\pth\\telehealth-frontend> yarn start yarn run v1.17.3 $ npm run build-css && react-scripts start

Covid19-Tele-Health@0.1.0 build-css D:\\Repos\\pth\\telehealth-frontend node-sass-chokidar src/styles/App.scss -o src/styles Covid19-Tele-Health@0.1.0 build-css D:\\Repos\\pth\\telehealth-frontend node-sass-chokidar src/styles/App.scss -o src/styles

Rendering Complete, saving .css file... Wrote CSS to D:\\Repos\\pth\\telehealth-frontend\\src\\styles\\App.css渲染完成,保存 .css 文件... 将 CSS 写入 D:\\Repos\\pth\\telehealth-frontend\\src\\styles\\App.css

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-rewired package provided by Create React App requires a dependency: Create React App 提供的 react-scripts-rewired 包需要一个依赖:

"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:

D:\\node_modules\\babel-eslint (version: 9.0.0) D:\\node_modules\\babel-eslint(版本:9.0.0)

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 D:\\node_modules\\babel-eslint is outside your project directory.检查 D:\\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-rewired) installed babel-eslint.这将告诉您安装了 babel-eslint 的其他软件包(除了预期的 react-scripts-rewired)。

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 我们知道这条消息很长,但请阅读上面的步骤 :-) 我们希望它们对您有所帮助!

error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.错误命令失败,退出代码为 1。信息 访问https://yarnpkg.com/en/docs/cli/run获取有关此命令的文档。

Any help is appreciated任何帮助表示赞赏

The error is because you have manually installed babel-eslint of version 9.0.0 but react-scripts require babel-eslint of version 10.0.2 .错误是因为您手动安装了9.0.0版的babel-eslintreact-scripts需要10.0.2版的babel-eslint

You have to run yarn remove babel-eslint and then run yarn install你必须运行yarn remove babel-eslint然后运行yarn install

This will install all the required dependencies from your package.json这将从您的package.json安装所有必需的依赖项

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

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