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

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

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

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

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




相关推荐
光影少年2 小时前
angular生态及学习路线
前端·学习·angular.js
无尽夏_4 小时前
HTML5(前端基础)
前端·html·html5
Jagger_4 小时前
敏捷开发流程-精简版
前端·后端
FIN66684 小时前
昂瑞微冲刺科创板:创新驱动,引领射频芯片国产化新征程
前端·安全·前端框架·信息与通信·芯片
GISer_Jing4 小时前
ByteDance——jy真题
前端·javascript·面试
睡美人的小仙女1274 小时前
浏览器为何屏蔽本地文件路径?
前端
真的想不出名儿4 小时前
Vue 中 props 传递数据的坑
前端·javascript·vue.js
FIN66684 小时前
昂瑞微:深耕射频“芯”赛道以硬核实力冲刺科创板大门
前端·人工智能·科技·前端框架·信息与通信·智能
阳光阴郁大boy4 小时前
星座运势网站技术解析:从零打造现代化Web应用
前端·javascript
烛阴5 小时前
武装你的Python“工具箱”:盘点10个你必须熟练掌握的核心方法
前端·python