Nodejs修改全局倉庫設置方案


一、默認情況下nodejs內置的npm會把模塊緩存在:“C:\Users\用戶\AppData\Roaming\npm”
打開cmd -> 輸入命令 npm config ls ,查看系統默認的npm倉庫目錄。

C:\Users\Daniel>npm config ls
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.10 node/v14.15.4 win32 x64"

; builtin config undefined
prefix = "C:\\Users\\Daniel\\AppData\\Roaming\\npm"

; node bin location = D:\JavaFile\Nodejs\node.exe
; cwd = C:\Users\Daniel
; HOME = C:\Users\Daniel
; "npm config ls -l" to show all defaults.

二、設置自定義全局倉庫,新建model和cache。其中module對應prefix,cache對應cache。

npm config set prefix "D:\JavaFile\Nodejs\model"
npm config set cache "D:\JavaFile\Nodejs\cache" 

三、查看配置是否生效

C:\Users\Daniel>npm config ls
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.10 node/v14.15.4 win32 x64"

; userconfig C:\Users\Daniel\.npmrc
cache = "D:\\JavaFile\\Nodejs\\cache"
prefix = "D:\\JavaFile\\Nodejs\\model"

; builtin config undefined

; node bin location = D:\JavaFile\Nodejs\node.exe
; cwd = C:\Users\Daniel
; HOME = C:\Users\Daniel
; "npm config ls -l" to show all defaults.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM