Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing old versions of create-react-app

I wanted to create a new react app using the create-react-app script. I still had a global version installed which is not supported anymore so I uninstalled the global version and tried creating a new one like this:

npx create-react-app myapp

I then got an error of no template used and that I probably use an older version of create-react-app. I read online and this DID work:

npx --ignore-existing create-react-app myapp

I read that it means I still got an older version even though I did uninstall the global version. So how do I remover any other older version of create-react-app?

like image 574
Yonatan Nir Avatar asked Sep 05 '25 03:09

Yonatan Nir


2 Answers

The following steps solved the problem of removing an old version and creating a create-react-app.

1 Check version of create-react-app, using npx create-react-app -V.

2 Uninstall any global version of create-react-app, using either npm uninstall -g create-react-app or yarn global remove create-react-app.

3 View the contents of your machine _npx folder, each folder inside represents a version of node installed. Use ls -a /Users/<username>/.npm/_npx/.

4 View the version of create-react-app in a node version found in step 3 in the package.json file. Example nano /Users/<username>/.npm/_npx/c67e74de0542c87c/package.json.

5 Delete the node version folder. Example rm -rf /Users/<username>/.npm/_npx/c67e74de0542c87c. It will get recreated when you run step 6. Alternatively, you can rename the folder to be safe.

6 Create react app. npx create-react-app my-app. You should see the prompt to proceed app creation.

like image 196
Apex Avatar answered Sep 08 '25 16:09

Apex


The npx is a tool to execute packages and npm is a tool mainly used to install packages. That's means if you want to execute a package without installing it on your computer and then launch it you can use npx directly.

Uninstall the library globally
Use npm uninstall -g create-react-app then check if is it removed successfully from your machine using which create-react-app. If still exist delete it manually.

Linux

rm -rf /usr/local/bin/create-react-app
  • -r -- attempt to remove the file hierarchy rooted in each file argument i.e. recursively remove subdirectories and files from the specified directory.
  • -f -- attempt to remove the files without prompting for confirmation, regardless of the file’s permissions

Windows

del /f/s/q C:\nodejs\node_modules\npm\bin\create-react-app > nul
rmdir /s/q C:\nodejs\node_modules\npm\bin\create-react-app
  • /f -- forces the deletion of read-only files.
  • /q -- enables quiet mode. You are not asked if it is ok to delete files (if you don't use this, you are asked for any file in the folder).
  • /s -- runs the command on all files in any folder under the selected structure.

Finally you able to use the last version with npx create-react-app myapp.

like image 24
Abdelrhman Arnos Avatar answered Sep 08 '25 17:09

Abdelrhman Arnos