This concise article shows you how to change the npm cache folder in Windows and macOS. Without any further ado, let’s get started.
Windows
The default npm cache folder in Windows is:
%AppData%/npm-cache
You can set your own custom path for the global cache by running the following command:
npm config set cache [your custom path] --global
An explicit example:
npm config set cache D:\kindacode\nodejs\npm-cache --global
If you encounter errors, just wrap the path with the double quotes (” “).
Mac
This is the default npm cache directory on Mac:
~/.npm
You can change it by running npm config set cache as follows:
npm config set cache /Users/goodman/Desktop/npm-cache --global
Don’t forget to replace /Users/goodman/Desktop/npm-cache with your own path.
Further reading:
- 2 Ways to Set Default Time Zone in Node.js
- NPM: How To Show All Globally Installed Packages
- Node.js: The Maximum Size Allowed for Strings/Buffers
- Best Open-Source HTTP Request Libraries for Node.js
- Node.js: Reading and Parsing Excel (XLSX) Files
You can also check out our Node.js category page for the latest tutorials and examples.