How to change NPM cache location (Windows & Mac)

Updated: March 19, 2022 By: A Goodman Post a comment

This concise article shows you how to change the npm cache folder in Windows and macOS. Without any further ado, let’s get started.


The default npm cache folder in Windows is:


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 (” “).


This is the default npm cache directory on Mac:


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.

Notify of
Inline Feedbacks
View all comments

Related Articles