cnpm是淘寶團隊開發的一個針對中國用戶的npm鏡像源,它是npm的一個定制版本。由于國外的npm源在國內訪問速度較慢,所以cnpm鏡像源可以提供更快的下載速度。cnpm的使用方式與npm基本相同,只需將`npm`替換為`cnpm`即可。
要想使用cnpm等先安裝node.js。具體安裝查看
windows下安裝node.js
?配置nodejs淘寶鏡像加速器
npm config set registry https://registry.npmmirror.com
檢查鏡像配置
npm config get registry
查看配置
npm config list
安裝cnpm
-g :全局安裝
npm install cnpm -g --registry=https://registry.npmmirror.com
查看cnpm
cnpm -v
安裝成功
錯誤解決一
PS D:\Program Files\nodejs> npm install cnpm -g --registry=https://registry.npmmirror.com
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path D:\Program Files\nodejs\node_global\node_modules
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'D:\Program Files\nodejs\node_global\node_modules'
npm ERR! [Error: EPERM: operation not permitted, mkdir 'D:\Program Files\nodejs\node_global\node_modules'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'D:\\Program Files\\nodejs\\node_global\\node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.npm ERR! A complete log of this run can be found in: D:\Program Files\nodejs\node_cache\_logs\2024-02-29T05_56_20_824Z-debug-0.log
PS D:\Program Files\nodejs>
這個錯誤是由于權限問題導致的。npm
嘗試在
D:\Program Files\nodejs\node_cache\_cacache
D:\Program Files\nodejs\
node_global\
node_modules
目錄下創建一個文件夾,但由于權限不足而失敗。
-
打開文件資源管理器,導航到
D:\Program Files\nodejs\
node_global\
node_modules目錄。 -
右擊目錄,選擇“屬性”。
-
切換到“安全”標簽頁,點擊“編輯”。
-
選擇你的用戶賬戶,勾選“完全控制”權限。
-
點擊“應用”和“確定”保存更改。