Deleting a react-app

Deleting a react app from your local development environment is typically straightforward. To do so, just delete the folder in which your source files reside.

For example, if you’ve built your application using the create-react-app npx command, you just need to delete the folder that this command created (along with its subfolders).

If your solution includes symbolic links to other directories or contains git submodules, then you may need to approach this from another way. I would suggest removing all linked directories before removing the directory that the app is in. Git submodules should be removed along with the rest of the files, as these are plain files.

delete-react-app

There is no delete-react-app as a direct opposite to the create-react-app script available in NPM. Deleting a react app is a manual process to remove all source files and associated third-party packages you may have added to the application.

Why is deleting the react app so slow?

Typically, your source files and media are quite quick to delete when deleting a react app. The slowness in deleting the app generally comes from deleting the node_modules folder.

The node_modules folder contains all third-party libraries your app uses. The list of these apps can be found in your package.json file in the base directory of the app. Inside this file, there are two sections where node_modules libraries are listed. 

The first is under the dependencies property, the second is under the devDependencies property. When you look at the folders inside the node_modules folder, you will notice that there are a lot more folders than you have items in dependencies and devDependencies.

This discrepancy comes from the dependencies of your dependency. For example, if we take the npm package eslint as an example, it has 39 dependencies. So if your application only had one dependency of eslint, your node_modules folder would have at least 39 folders.

When using the graphical way to delete a react app, due to a large number of files in the node_modules directory, the process can be very slow. The quicker way to delete the files is by using the command line, Terminal for macOS/Linux and Powershell for Windows.

Deleting a react-app in MacOS

In macOS, there are two main ways to delete the react app. The first is to use Finder and to move the files to the Bin. The other is to use the Terminal and manually delete the files from the command line.

To delete the files using Finder, locate the directory that your react app is in. Right-click this folder and click the Move to Bin menu item. If you want to remove the folder completely from the computer, right-click the Bin icon in your dock and select Empty Bin.

To delete the react app using the Terminal app, open a new Terminal instance and navigate to the parent directory where your react app is. From here, run an rm -rf your_folder_name command to delete the react app.

The -rf tells the remove command to remove all files in subdirectories recursively and not to prompt for a yes/no on every file it is about to delete. 

Deleting files by using the command line is much faster than the graphical way using the Bin.

Deleting a react-app in Windows

In Windows, you can delete your react app from File Explorer or use Powershell. Using Powershell, like Terminal in macOS, is the quickest way to delete your react ap.

To delete the files using File Explorer, locate the directory that your react app is in. Right-click this folder and click the Delete menu item. If you want to remove the folder completely from the computer, right-click the Bin icon on your desktop and select Empty Recycle Bin.

To delete the react app using Powershell, open a new Powershell instance and navigate to the parent directory where your react app is. From here, run an Remove-Item -Recurse –Force your_folder_name command to delete your react app.

Deleting a react-app in Linux (Ubuntu)

In Ubuntu, there are two main ways to delete your react app. One is to use the Files app and the other, like macOS, is to use the Terminal app.

To delete the app using Files, navigate to the parent directory where your react app folder is. Right-click the folder and select Move to Trash from the context menu. Find the bin icon on your desktop, right-click, and select Empty Trash to remove the react app from your computer completely.

To delete the react app using the Terminal app, open a new Terminal instance and navigate to the parent directory where your react app is. From here, run an rm -rf your_folder_name command to delete the react app.

The -rf tells the remove command to remove all files in subdirectories recursively and not to prompt for a yes/no on every file it is about to delete. 

Troubleshooting deleting your react app

If you are being presented with errors when deleting the react app, you should check

  • That the app is not currently running
  • That you have the appropriate permissions to delete the directory
  • That no other application has locked a file in the react app directory

For points 1 and 3 above, if you logged out and then logged back into your system, you should have reset the state of the application and will now be able to delete the directory.

For point 2, you may need to see your system administrator to be given the appropriate permissions.

Conclusion

Deleting a react app is the same as deleting any folder from your operating system (in most cases). Just follow the normal steps to remove a folder, and you should be OK. 

Facing errors from the operating system when deleting the folder most likely means that the folder is open in another application, like VS Code or nodejs is possibly holding a lock on the build directory, causing you not to be able to delete the directory.

Finally, react app folders can be slowly deleted due to the many files in the node_modules directory. For this reason, it is quicker to remove the files via the command line than to remove files using the graphical interface of your operating system.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments