简体   繁体   English

如何使用最新的 React 版本 (react18)?

[英]How can I use the latest react version (react18)?

When using npx create-react-app my-app, I got this error:使用 npx create-react-app my-app 时,我得到了这个错误:

You are running create-react-app 4.0.3, which is behind the latest release (5.0.1).您正在运行create-react-app 4.0.3,它落后于最新版本 (5.0.1)。 We no longer support global installation of Create React App.我们不再支持全局安装 Create React App。 Please remove any global installs with one of the following commands: - npm uninstall -g create-react-app - yarn global remove create-react-app请使用以下命令之一删除任何全局安装:- npm uninstall -g create-react-app - yarn global remove create-react-app

I used the command npm uninstall and also check out the getting started with react我使用命令 npm uninstall 并检查了getting started with react

but that links suggest the same process of npx create-react-app my-app.但该链接表明 npx create-react-app my-app 的过程相同。 I also used this command npm install react react-dom but this我也使用了这个命令npm install react react-dom但是这个
only install a node modules and a package.json.只安装一个节点模块和一个 package.json。 It doesn't create the usual react boilerplate and all.它不会创建通常的反应样板和所有内容。 Anyone have any idea, please help.任何人有任何想法,请帮助。

Try this solution:试试这个解决方案:

npx create-react-app@latest myApp

You first need to uninstall the glocal app and then clear the cache and then reinstall it.您首先需要卸载 glocal 应用程序,然后清除缓存,然后重新安装。

npm uninstall -g create-react-app

npx clear-npx-cache

After doing this reinstall it by running following command执行此操作后,通过运行以下命令重新安装它

npx create-react-app my-app

If it still don't work make sure to update your npm and node version.如果它仍然不起作用,请确保更新您的 npm 和节点版本。

暂无
暂无

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

相关问题 我如何通过此错误无效的挂钩调用。 钩子只能在 function 组件的主体内部调用。 我正在使用 React18 - How do i get pass this error Invalid hook call. Hooks can only be called inside of the body of a function component. i am using React18 WebSocket 升级到 react18 后断开连接 - WebSocket gets disconnected after upgrade to react18 如何在 React18 中成功登录 Google 后重定向到另一个页面? - How to redirect to another page after successful Google Sign In in React18? 如何在 React 18 中使用“useEffect” - How do I use 'useEffect' in React 18 我们如何在最新版本的 React Navigation v6 中使用(或替代方法)switchNavigator v4(React Navigation)? - How can we use (or alternate method of) switchNavigator v4 (React Navigation) in the latest version React Navigation v6? 如何在 react js 中使用 useInvertedScale 和最新的成帧器运动版本? - How to use useInvertedScale with the latest framer motion version in react js? React18 中的 SSR 使用 renderToPipableStream - 服务器生成的 HTML 和客户端 HTML 文件 UI 不匹配 - SSR in React18 using renderToPipableStream - Server Generated HTML and Client Side HTML file UI are not matching 如何在最新版本的React Native中使用Navigator? - How can I use Navigator in the newest version of React Native? 如何在 React Native 中使用 i18next 进行本地化 - how to use i18next in react native for localisation React - 如何在 antd 表中使用 i18nNext - React - how to use i18nNext in antd table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM