Reactjs 无法创建项目
我试图使用命令创建一个react项目Reactjs 无法创建项目,reactjs,npm,npx,Reactjs,Npm,Npx,我试图使用命令创建一个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-
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,并查看是否修复了它,如果没有,您可以尝试以下步骤
如果您以前通过npm install-g create react app
全局安装过create react app
,建议您使用npm uninstall-g create react app
或warn global remove create react app
卸载软件包,以确保npx
始终使用最新版本
您还需要删除聊天应用程序
一旦进入/home/mikhil/react tutorial/intersphala react course
目录并删除了全局安装,就可以尝试运行这些命令
npx create-react-app my-app
cd my-app
npm start
似乎有一些特定版本的NPM会导致此问题。尝试更新到NPM的最新版本。我一整天都在尝试更新,最后我不得不打开文档,上面提到你也可以使用
npm init create-react-app **app_name**
这对我来说很好,你用的是什么版本的Node和NPM?