menu

Questions & Answers

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

When using npx create-react-app my-app, I got this error:

You are running create-react-app 4.0.3, which is behind the latest release (5.0.1). We no longer support global installation of 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

I used the command npm uninstall and also check out the getting started with react

but that links suggest the same process of npx create-react-app my-app. I also used this command npm install react react-dom but this
only install a node modules and a package.json. It doesn't create the usual react boilerplate and all. Anyone have any idea, please help.

Comments:
2023-01-07 20:29:51
I ran into this. Try npx create-react-app@latest myApp.
2023-01-07 20:29:51
what version of node and npm are you using?
2023-01-07 20:29:51
@TungPham node = v15.10.0 npm = 7.5.3
2023-01-07 20:29:51
Looks like you instal create-react-app in global scope. Remove it ( console output suggests 2 variants) and call npx again
2023-01-07 20:29:51
@Andy , it worked. Thanks 🙏
2023-01-07 20:29:51
@Andy , from now on, do I have to use a command to install the latest react everytime or can I just use npx create-react-app@latest my-app ???
2023-01-07 20:29:51
I'd just do the second thing. I don't have CRA installed globally and that's the only thing that works. @Rabten. I'm too lazy to figure out another solution :/
2023-01-07 20:29:51
@Andy Ok Thank you again.
Answers(2) :

You first need to uninstall the glocal app and then clear the cache and then reinstall it.

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.

Try this solution :

npx create-react-app@latest myApp