Should I backup the ".npm" and ".node-gyp" folder?

Erel Segal-Halevi picture Erel Segal-Halevi · Nov 15, 2013 · Viewed 7.8k times · Source

I am working on a backup plan for my hard-drive, and I would like to know whether there is any need to backup the hidden folders "~/.npm" and "~/.node-gyp"? Or they are just temporary folders whose content is built automatically?

Answer

Paul Mougel picture Paul Mougel · Nov 15, 2013

The ~/.npm folder is a cache folder that contains local packages so that you don't have to download them over and over when you install them in a new project. You can safely delete this folder and you can in fact do it using the npm cache command:

$ npm cache clean

The ~/.node-gyp folder is the devDir of node-gyp (see relevant source code). This is where development header files are copied in order to perform the compilation of native modules. you can safely delete this directory, as it will be re-created the next time you'll install a module that needs node-gyp.