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 小时前
css预编译器实现星空背景图
前端·css·vue3
wyiyiyi2 小时前
【Web后端】Django、flask及其场景——以构建系统原型为例
前端·数据库·后端·python·django·flask
gnip3 小时前
vite和webpack打包结构控制
前端·javascript
excel3 小时前
在二维 Canvas 中模拟三角形绕 X、Y 轴旋转
前端
阿华的代码王国3 小时前
【Android】RecyclerView复用CheckBox的异常状态
android·xml·java·前端·后端
一条上岸小咸鱼3 小时前
Kotlin 基本数据类型(三):Booleans、Characters
android·前端·kotlin
Jimmy3 小时前
AI 代理是什么,其有助于我们实现更智能编程
前端·后端·ai编程
ZXT4 小时前
promise & async await总结
前端
Jerry说前后端4 小时前
RecyclerView 性能优化:从原理到实践的深度优化方案
android·前端·性能优化
画个太阳作晴天4 小时前
A12预装app
linux·服务器·前端