Kinda Code
Home/Node/How to change NPM cache location (Windows & Mac)

How to change NPM cache location (Windows & Mac)

Last updated: March 19, 2022

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:

You can also check out our Node.js category page for the latest tutorials and examples.