Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restore/reset npm configuration to default values?

Tags:

node.js

npm

I have played with npm set and npm config set for several times, now I want to reset to default values (a kind of factory reset).

Does npm provide a command to do that? Or should I delete all configuration files by hands then reinstall it?

I need to do it both on Linux CentOS and on Windows 8.

like image 702
damphat Avatar asked Jan 05 '14 13:01

damphat


People also ask

How do I reset my npm environment?

npm config edit Opens the config file in an editor. Use the --global flag to edit the global config. now you can delete what ever the registry's you don't want and save file. npm config list will display the list of available now.

How do I do a clean install of npm?

There are two ways to clean up the node_modules folder: Delete the folder and reinstall. Use npm prune (starting with npm version 6)


2 Answers

To reset user defaults

Run this in the command line (or git bash on windows):

echo "" > $(npm config get userconfig) npm config edit 

To reset global defaults

echo "" > $(npm config get globalconfig) npm config --global edit 

If you need sudo then run this instead:

sudo sh -c 'echo "" > $(npm config get globalconfig)' 
like image 62
Ilan Frumer Avatar answered Oct 02 '22 09:10

Ilan Frumer


For what it's worth, you can reset to default the value of a config entry with npm config delete <key> (or npm config rm <key>, but the usage of npm config rm is not mentioned in npm help config).

Example:

# set registry value npm config set registry "https://skimdb.npmjs.com/registry" # revert change back to default npm config delete registry 
like image 36
David Silva Avatar answered Oct 02 '22 10:10

David Silva