Visual Studio Code (VS Code) is a popular and versatile code editor beloved by developers worldwide. However, like any software, it can encounter performance issues, extension errors or unexpected behavior.
7 Ways to Clear VS Code Cache
- Clearing the extension cache.
- Clearing the workspace storage.
- Clearing user data cache.
- Clearing editor cache.
- Clearing extension host cache.
- Clearing node modules cache for extension developers.
- Restart VS code.
I wasted an hour fixing an issue that could’ve been solved by just clearing cache and removing a few lines in settings.json
.
One effective way to troubleshoot these problems is to clear the various caches that VS Code uses. In this blog post, I’ll guide you through the process of clearing different types of caches in VS Code to help you maintain a smooth and efficient coding environment.
7 Ways to Clear VS Code Caches
1. Clearing Extension Cache
Extensions are a crucial part of the VS Code ecosystem, adding functionality and enhancing productivity. However, they can sometimes cause issues or conflicts. Here’s how to clear the extension cache:
- Uninstall Extensions: Open the Extensions view by pressing
Ctrl+Shift+X
(orCmd+Shift+X
on macOS). Right-click on the extension you want to remove and select “Uninstall.” - Reinstall Extensions: After uninstalling, you can reinstall the necessary extensions from the extensions view.
2. Clearing Workspace Storage
Workspace storage holds various data related to your workspace, which can accumulate and cause issues over time. Here’s how to clear its cache:
- Open command palette: Press
Ctrl+Shift+P
(orCmd+Shift+P
on macOS). - Search for
Developer: Open Workspace Storage
: This will open the folder where workspace storage files are kept. - Delete workspace storage files: In the opened folder, delete all the files and folders to clear the workspace storage.
3. Clearing User Data Cache
User data includes settings, snippets, keybindings and more. Resetting user data can resolve various problems.
1. Navigate to the User Data Folder:
- Windows:
C:\Users\\AppData\Roaming\Code\User
- macOS:
/Users//Library/Application Support/Code/User
- Linux:
~/.config/Code/User
2. Delete Specific Files
You can delete specific files like settings.json
, keybindings.json
, etc., or delete the entire user folder to reset all user data. Or you can remove targeted lines to avoid much more chaos.
4. Clearing the Editor Cache
Clearing the editor cache can help if you’re experiencing issues related to the editor itself.
Clear Temporary Files
- Windows: Use Disk Cleanup or manually delete files in
C:\Users\\AppData\Local\Temp
- macOS: Clear cache in
/private/var/folders
- Linux: Clear cache in
/tmp
5. Clearing Extension Host Cache
If you’re still facing issues, clearing the extension host cache might be necessary.
1. Navigate to the Extension Host Cache Folder
- Windows:
C:\Users\\AppData\Roaming\Code\CachedData
- macOS:
/Users//Library/Application Support/Code/CachedData
- Linux:
~/.config/Code/CachedData
2. Delete Cache Data
Delete all the contents of the CachedData
folder.
6. Clearing Node Modules Cache for Extension Developers
If you’re developing extensions or using Node.js within VS Code, clearing the Node modules cache can be helpful.
- Delete
node_modules
Folder: Navigate to your project directory and delete thenode_modules
folder. - Clear npm Cache: Run
npm cache clean --force
in the terminal.
7. Restart VS Code
After clearing the caches, restart VS Code to apply the changes.
Additional Tips to Clear VS Code Cache
- Backup Settings: Before clearing caches, back up your settings, keybindings, snippets and other configurations.
- Update VS Code: Ensure you’re using the latest version of VS Code, as updates often resolve existing issues.
Frequently Asked Questions
Why is it important to clear VS Code cache?
Clearing the cache in VS Code is a useful way to troubleshoot common issues like slowed performance, extension errors and unexpected behavior. It can help users maintain a smooth and efficient coding environment.
How to clear the data of a VS Code extension?
- Uninstall Extensions: Press
Ctrl+Shift+X
(orCmd+Shift+X
on macOS) to open the extension view. Right-click on the extension you want to remove, and select “Uninstall.” - Reinstall Extensions: After uninstalling, you can reinstall the necessary extensions from the extensions view.