npm

global npm configuration settings

Snippet

npm has a number of configuration values you can set. While some are located in ~/.npmrc not all are. Use npm config list (or npm config ls) to see what is available:

$ npm config list
; cli configs
user-agent = "npm/2.12.1 node/v0.12.7 darwin x64"

; userconfig /Users/kitt/.npmrc
registry = "https://npm.example.com/"

; builtin config undefined
prefix = "/usr/local"

; node bin location = /usr/local/bin/node
; cwd = /Users/kitt/work/projects/twitter-project
; HOME = /Users/kitt
; 'npm config ls -l' to show all defaults.

Note that npm config list -l will show the defaults, with the overridden ones commented out:

bash-3.2$ npm config list -l
; cli configs
long = true
user-agent = "npm/2.12.1 node/v0.12.7 darwin x64"

; userconfig /Users/kitt/.npmrc
registry = "https://npm.example.com/"

; builtin config undefined
prefix = "/usr/local"

; default values
access = null
always-auth = false
bin-links = true
browser = null
ca = null
cache = "/Users/kitt/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cafile = undefined
cert = null
color = true
depth = null
description = true
dev = false
editor = "vi"
engine-strict = false
...

I clearly need to change that editor default...

# list all npm configurations we've set
npm config list
 
# list all the settings, AND the defaults
npm config ls -l
 
# set a configuration value
npm config set registry https://npm.example.com/
 
# unset a configuration value
npm config rm registry

Upgrade Node.js via NPM and n

Snippet

Upgrade local npm via the command line using n

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Fix "npm ERR! Error: No compatible version found:" errors by upgrading

Blog

Fix "ERR! Error: No compatible version found: browser-sync-client@'^0.1.7'" errors with npm by upgrading your node version.

Barfs:

$ node --version 
v0.10.9

Works:

bash-3.2$ node --version 
v0.10.28
npm http 200 https://registry.npmjs.org/browser-sync-control-panel/0.0.5
npm http GET https://registry.npmjs.org/commander/-/commander-2.1.0.tgz
npm ERR! Error: No compatible version found: browser-sync-client@'^0.1.7'
npm ERR! Valid install targets:
npm ERR! ["0.0.2","0.0.3","0.0.4","0.0.5","0.1.0","0.1.1","0.1.2","0.1.3","0.1.4","0.1.5","0.1.6","0.1.7","0.1.8"]
npm ERR!     at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache.js:709:10)
npm ERR!     at /usr/local/lib/node_modules/npm/lib/cache.js:631:10
npm ERR!     at saved (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:

Also recommended:

$ npm cache clear
$ npm rebuild