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

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

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

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

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




相关推荐
kyriewen10 小时前
我手写了一个 EventEmitter,面试官追问了 6 个问题——第 4 个我没答上来
前端·javascript·面试
IT_陈寒10 小时前
Java的Date类又坑了我一次,改用时间戳真香
前端·人工智能·后端
小林攻城狮10 小时前
使用 Transport 节流解决 Vercel AI SDK 流式渲染卡死问题
前端·react.js
前端缘梦11 小时前
告别 TS 运行时类型漏洞!Zod 完整入门实战教程(前端 / 全栈必备)
前端·react.js·全栈
the_answer11 小时前
Webpack vs Vite 深度对比分析
前端·webpack
转转技术团队11 小时前
验证码识别实战:前端不写页面,改训模型了?
前端
MomentYY11 小时前
Temperature:AI 的“脑洞旋钮”
前端·llm·ai编程
远航_11 小时前
OpenSpec 完整详细介绍
前端·后端
召钱熏12 小时前
状态枚举正确≠渲染正确:一个语音按钮的状态机边界修复实录
android·前端
SkyWalking中文站12 小时前
认识 Horizon UI · 1/17:SkyWalking 新一代可观测性控制台
运维·前端·监控