windows下安装cnpm

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目录。

  • 右击目录,选择"属性"。

  • 切换到"安全"标签页,点击"编辑"。

  • 选择你的用户账户,勾选"完全控制"权限。

  • 点击"应用"和"确定"保存更改。




相关推荐
LaoZhangAI6 分钟前
Google Gemini AI图片编辑完全指南:50+中英对照提示词与批量处理教程(2025年9月)
前端·后端
用户114818678948410 分钟前
从零搭建 Vue3 + Nest.js 实时通信项目:4 种方案(短轮询 / 长轮询 / SSE/WebSocket)
前端·后端
LaoZhangAI11 分钟前
Google Gemini Nano与Banana AI完整部署指南:2025年轻量级AI解决方案
前端·后端
用户114818678948416 分钟前
基于 Webpack Module Federation 的 Vue 微前端实践
前端
怪可爱的地球人16 分钟前
Pinia状态管理有哪些常用API?
前端
小高00717 分钟前
🤔函数柯里化:化繁为简的艺术与实践
前端·javascript·面试
却尘20 分钟前
React useMemo 依赖陷阱:组件重挂载,状态无限复原
前端·javascript·react.js
Asort24 分钟前
JavaScript 从零开始(三):浏览器控制台与VS Code协同工作环境搭建详解
前端·javascript
跟橙姐学代码25 分钟前
自动化邮件发送的终极秘籍:Python库smtplib与email的完整玩法
前端·python·ipython
我是ed1 小时前
# vue3 实现甘特图
前端