gpt4 book ai didi

reactjs - 无法创建 react 项目

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

我试图使用命令创建一个 react 项目

npx create-react-app chat-app
但我收到此错误。
Creating a new React app in /home/mikhil/react-tutorial/internshala-react-course/chat-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! npm ERR! Found: @babel/core@undefined
npm ERR! node_modules/@babel/core npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @babel/core@"^7.0.0-0" from @babel/preset-env@7.13.10
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! react-scripts@"*" from the root project
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 /home/mikhil/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/mikhil/.npm/_logs/2021-03-18T11_58_50_255Z-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 chat-app/ from /home/mikhil/react-tutorial/internshala-react-course
Done.

最佳答案

您可以尝试使用 npm update 更新 npm看看是否能解决它,如果不能,你可以尝试这些步骤。
如果您以前安装过 create-react-app全局通过 npm install -g create-react-app ,建议您使用 npm uninstall -g create-react-app 卸载软件包或 yarn global remove create-react-app确保npx始终使用最新版本。
您还需要删除 chat-app 的剩余文件和文件夹。
一旦您在 /home/mikhil/react-tutorial/internshala-react-course目录并且您已经删除了全局安装,您可以尝试运行这些命令。

npx create-react-app my-app
cd my-app
npm start
Create React App - Getting Started

关于reactjs - 无法创建 react 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66690811/

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