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

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

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

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

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




相关推荐
源码获取_wx:Fegn089513 分钟前
基于springboot + vue健身房管理系统
java·开发语言·前端·vue.js·spring boot·后端·spring
闲谈共视18 分钟前
基于去中心化社交与AI智能服务的Web钱包商业开发的可行性
前端·人工智能·去中心化·区块链
CreasyChan27 分钟前
C# 反射详解
开发语言·前端·windows·unity·c#·游戏开发
JIngJaneIL1 小时前
基于Java+ vue智慧医药系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
温正实1 小时前
如何下载源码运行全栈项目
node.js
你真的可爱呀2 小时前
1.基础环境搭建与核心认知
node.js·express
hashiqimiya2 小时前
两个步骤,打包war,tomcat使用war包
java·服务器·前端
零度@3 小时前
Java中Map的多种用法
java·前端·python
yuanyxh3 小时前
静默打印程序实现
前端·react.js·electron
三十_A4 小时前
如何正确实现圆角渐变边框?为什么 border-radius 对 border-image 不生效?
前端·css·css3