I am having problems with npx create-react-app involving global installs. My confusion arises because as far as I'm aware the create-react-app package is not installed on my machine.
Some Details:
I start a react project (with typescript template) as I have previously and recently done on this same machine a number of times:
npx create-react-app --template typescript .
I get this prompt from the terminal
Need to install the following packages: create-react-app Ok to proceed? (y)
I press y to confirm it's okay to proceed. (If I press n, the process terminates with the following error: npm ERR! canceled
.) The terminal then displays the following message
You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).
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
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
I run both suggested commands to uninstall create-react-app globally. npm goes smoothly:
npm uninstall -g create-react-app
up to date, audited 1 package in 179ms
found 0 vulnerabilities
the global yarn uninstall results with the following message:
remove create-react-app
yarn global v1.22.17
warning package.json: No license field
[1/2] π Removing module create-react-app...
error This module isn't specified in a package.json file.
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
Finally I try to find if create-react-app exists on my machine with
which create-react-app
which results in
create-react-app not found
.
I'm not sure how else to address this issue.
Edit: Solution provided by Deepthi and Sators. I had to clear the npx cache which had stored an older version of create-react-app by using command:
npx clear-npx-cache