gpt4 book ai didi

node.js - 由于与 babel 的依赖关系,安装 react 时出现问题

转载 作者:行者123 更新时间:2023-12-04 12:29:19 28 4
gpt4 key购买 nike

基本上这个。我试过两者

npm init react-app my-app
npx create-react-app my-app
我总是收到这条消息:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: @babel/core@7.12.3
npm ERR! node_modules/@babel/core
npm ERR! @babel/core@"7.12.3" from react-scripts@4.0.3
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"*" from the root project
npm ERR! @babel/core@"^7.12.3" from @svgr/webpack@5.5.0
npm ERR! node_modules/@svgr/webpack
npm ERR! @svgr/webpack@"5.5.0" from react-scripts@4.0.3
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"*" from the root project
npm ERR! 9 more (babel-jest, babel-loader, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @babel/core@"^7.13.0" from @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.13.12
npm ERR! node_modules/@babel/preset-env/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
npm ERR! @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@"^7.13.12" from @babel/preset-env@7.14.4
npm ERR! node_modules/@babel/preset-env
npm ERR! @babel/preset-env@"^7.12.1" from @svgr/webpack@5.5.0
npm ERR! node_modules/@svgr/webpack
npm ERR! @svgr/webpack@"5.5.0" from react-scripts@4.0.3
npm ERR! node_modules/react-scripts
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Zio Matteo\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Zio Matteo\AppData\Local\npm-cache\_logs\2021-06-08T08_46_00_758Z-debug.log

Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... package.json
Deleting first/ from C:\Users\Zio Matteo\Desktop\react
Done.
npm ERR! code 1
npm ERR! path C:\Users\Zio Matteo\Desktop\react
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c create-react-app "first"

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Zio Matteo\AppData\Local\npm-cache\_logs\2021-06-08T08_46_01_359Z-debug.log
我也更新了 Node ,但没有任何效果。我的 package.json 是空的,因为这是我尝试安装的第一个包,所以我也没有 node_modules 文件夹。我能做什么?

最佳答案

这是 npm 版本的问题。升级到最新版本的 npm:

npm install -g npm@latest
还添加 babel:
npm install --save-dev @babel/core
如果此解决方案不起作用,您可以简单地尝试旧的 npm 版本:
npm install npm@6.14.11 -g

关于node.js - 由于与 babel 的依赖关系,安装 react 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67884414/

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