Nodejs NPM package management configuration methods and common commands

  • 2020-03-30 03:10:46
  • OfStack

1. Enter NPM config ls -l to view the current directory Settings


; cli configs
long = true
; builtin config C:Program Files (x86)nodejsnode_modulesnpmnpmrc
prefix = "C:\Users\sam\AppData\Roaming\npm"
; default values
always-auth = false
browser = "start"
ca = "-----BEGIN CERTIFICATE-----nMIIChzCCAfACCQDauvz/KHp8ejANBgkqhkiG9w0BAQUFA
DCBhzELMAkGA1UEBhMCnVVMxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMQwwCgYDVQQKEwN
ucG0xnIjAgBgNVBAsTGW5wbSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxDjAMBgNVBAMTBW5wnbUNBMRc
wFQYJKoZIhvcNAQkBFghpQGl6cy5tZTAeFw0xMTA5MDUwMTQ3MTdaFw0ynMTA5MDIwMTQ3MTdaMIGHM
QswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEDAOBgNVnBAcTB09ha2xhbmQxDDAKBgNVBAoTA25wbTE
iMCAGA1UECxMZbnBtIENlcnRpZmljnYXRlIEF1dGhvcml0eTEOMAwGA1UEAxMFbnBtQ0ExFzAVBgkqh
kiG9w0BCQEWCGlAnaXpzLm1lMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLI4tIqPpRW+ACw9G
EnOgBlJZwK5f8nnKCLK629Pv5yJpQKs3DENExAyOgDcyaF0HD0zk8zTp+ZsLaNdKOznGn2U181KGpr
GKAXP6DU6ByOJDWmTlY6+Ad1laYT0m64fERSpHw/hjD3D+iX4aMOlny0HdbT5m1ZGh6SJz3ZqxavhHL
QIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAC4ySDbCnl7W1WpLmtLGEQ/yuMLUf6Jy/vr+CRp4h+UzL+IQ
pCv8FfxsYE7dhf/bmWTEupBkvnyNL18lipt2jSvR3v6oAHAReotvdjqhxddpe5Holns6EQd1/xEZ7sB
1YhQKJtvUrlnZNufy1Jf1r0ldEGeA+0ISck7s+xSh9rQD2Opn-----END CERTIFICATE-----"
cache = "C:\Users\sam\AppData\Roaming\npm-cache"
cache-max = null
cache-min = 0
color = true
coverage = false
depth = null
description = true
dev = false
editor = "notepad.exe"
force = false
git = "git"
global = false
globalconfig = "C:\Program Files (x86)\nodejs\etc\npmrc"
globalignorefile = "C:\Program Files (x86)\nodejs\etc\npmignore"
group = 0
ignore = ""
init-module = "C:\Users\sam\.npm-init.js"
init.version = "0.0.0"
init.author.name = ""
init.author.email = ""
init.author.url = ""
json = false
link = false
loglevel = "http"
; long = false (overridden)
message = "%s"
node-version = "0.8.0"
npaturl = "http://npat.npmjs.org/"
npat = false
onload-script = null
outfd = 1
parseable = false
pre = false
; prefix = "C:\Program Files (x86)\nodejs" (overridden)
production = false
proprietary-attribs = true
proxy = null
https-proxy = null
user-agent = "npm/1.1.32 node/v0.8.0"
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = false
save-bundle = false
save-dev = false
save-optional = false
searchopts = ""
searchexclude = null
searchsort = "name"
shell = "C:\windows\system32\cmd.exe"
strict-ssl = true
tag = "latest"
tmp = "C:\Users\sam\AppData\Local\Temp"
unicode = true
unsafe-perm = true
usage = false
user = 0
username = ""
userconfig = "C:\Users\sam\.npmrc"
userignorefile = "C:\Users\sam\.npmignore"
umask = "022"
version = false
versions = false
viewer = "browser"
yes = null
_exit = true

2. For a certain setting, it can be passed


npm config set  The property name   Attribute values 

The way to configure.

Such as:

npm config set prefix "C:123"

3. Read a configuration

npm config get prefix


4. Common NPM commands

npm install xxx  Install the module 
npm install xxx@1.1.1    The installation 1.1.1 Version of the xxx
npm install xxx -g  Install the module into the global environment. 
npm ls  View installed modules and dependencies 
npm ls -g  View the modules and dependencies for the global installation 
npm uninstall xxx  (-g)  Uninstall the module 
npm cache clean  Clear the cache 
npm help xxx   See the help 
npm view moudleName dependencies   View package dependencies 
npm view moduleNames   To view node The module package.json folder 
npm view moduleName labelName   To view package.json The contents of a label under a folder 
npm view moduleName repository.url   View the package's source file address 
npm view moduleName engines    View what the package depends on Node The version of the 
npm help folders    To view npm Use all folders 
npm rebuild moduleName     Used to rebuild after changing the package content 
npm outdated    Check if the package is out of date. This command lists all the packages that are out of date so that the package can be updated in a timely manner 
npm update moduleName    update node The module 


Related articles: