查看配置信息

npm config list

实例

C:\Users\qql1>npm config list
; "builtin" config from D:\1000software\1100productivity\node\node_global\node_modules\npm\npmrc
; prefix = "C:\\Users\\qql1\\AppData\\Roaming\\npm" ; overridden by user
; "user" config from C:\Users\qql1\.npmrc
//registry.npmjs.org/:_authToken = (protected)
cache = "D:\\1000software\\1100productivity\\node\\node_cache"
init-author-email = "2482076557@qq.com"
init-author-name = "qql1"
init-author-url = "http://github.com/qql2"
prefix = "D:\\1000software\\1100productivity\\node\\node_global"
; node bin location = D:\1000software\1100productivity\node\node.exe
; node version = v16.14.0
; npm local prefix = C:\Users\qql1
; npm version = 9.6.5
; cwd = C:\Users\qql1
; HOME = C:\Users\qql1
; Run `npm config ls -l` to show all defaults.

在npm配置中,有两个prefix配置项。其中一个是内置配置,另一个是用户配置。用户配置会覆盖内置配置。 因此,最终使用的是用户配置中的prefix,即D:\\1000software\\1100productivity\\node\\node_global

修改配置

child::npmrc

配置信息内容

prefix配置项

全局npm模块的保存位置

更新NPM

npm install npm -g