欢迎来到代码驿站!

NodeJS

当前位置:首页 > 脚本语言 > NodeJS

nodejs npm包管理的配置方法及常用命令介绍

时间:2021-03-23 09:33:28|栏目:NodeJS|点击:

1. 输入 npm config ls -l 可以查看当前的目录设置

复制代码 代码如下:

; cli configs
long = true

; builtin config C:\Program Files (x86)\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\sam\\AppData\\Roaming\\npm"

; default values
always-auth = false
browser = "start"
ca = "-----BEGIN CERTIFICATE-----\nMIIChzCCAfACCQDauvz/KHp8ejANBgkqhkiG9w0BAQUFA
DCBhzELMAkGA1UEBhMC\nVVMxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMQwwCgYDVQQKEwN
ucG0x\nIjAgBgNVBAsTGW5wbSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxDjAMBgNVBAMTBW5w\nbUNBMRc
wFQYJKoZIhvcNAQkBFghpQGl6cy5tZTAeFw0xMTA5MDUwMTQ3MTdaFw0y\nMTA5MDIwMTQ3MTdaMIGHM
QswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEDAOBgNV\nBAcTB09ha2xhbmQxDDAKBgNVBAoTA25wbTE
iMCAGA1UECxMZbnBtIENlcnRpZmlj\nYXRlIEF1dGhvcml0eTEOMAwGA1UEAxMFbnBtQ0ExFzAVBgkqh
kiG9w0BCQEWCGlA\naXpzLm1lMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLI4tIqPpRW+ACw9G
E\nOgBlJZwK5f8nnKCLK629Pv5yJpQKs3DENExAyOgDcyaF0HD0zk8zTp+ZsLaNdKOz\nGn2U181KGpr
GKAXP6DU6ByOJDWmTlY6+Ad1laYT0m64fERSpHw/hjD3D+iX4aMOl\ny0HdbT5m1ZGh6SJz3ZqxavhHL
QIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAC4ySDbC\nl7W1WpLmtLGEQ/yuMLUf6Jy/vr+CRp4h+UzL+IQ
pCv8FfxsYE7dhf/bmWTEupBkv\nyNL18lipt2jSvR3v6oAHAReotvdjqhxddpe5Holns6EQd1/xEZ7sB
1YhQKJtvUrl\nZNufy1Jf1r0ldEGeA+0ISck7s+xSh9rQD2Op\n-----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. 针对某一项设置,可以通过

复制代码 代码如下:

npm config set 属性名 属性值

的方式来进行配置。

例如:

复制代码 代码如下:
npm config set prefix "C:\123\"

3. 读取某一项配置

复制代码 代码如下:
npm config get prefix


4.npm的常用命令
复制代码 代码如下:

npm install xxx 安装模块
npm install xxx@1.1.1   安装1.1.1版本的xxx
npm install xxx -g 将模块安装到全局环境中。
npm ls 查看安装的模块及依赖
npm ls -g 查看全局安装的模块及依赖
npm uninstall xxx  (-g) 卸载模块
npm cache clean 清理缓存
npm help xxx  查看帮助
npm view moudleName dependencies  查看包的依赖关系
npm view moduleNames  查看node模块的package.json文件夹
npm view moduleName labelName  查看package.json文件夹下某个标签的内容
npm view moduleName repository.url  查看包的源文件地址
npm view moduleName engines   查看包所依赖的Node的版本
npm help folders   查看npm使用的所有文件夹
npm rebuild moduleName    用于更改包内容后进行重建
npm outdated   检查包是否已经过时,此命令会列出所有已经过时的包,可以及时进行包的更新
npm update moduleName   更新node模块

上一篇:深入理解Node module模块

栏    目:NodeJS

下一篇:NodeJS读取分析Nginx错误日志的方法

本文标题:nodejs npm包管理的配置方法及常用命令介绍

本文地址:http://www.codeinn.net/misctech/86091.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有