淘宝镜像配置
2.1 配置淘宝镜像
npm config set registry https://registry.npm.taobao.org
2.2 安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
通过cnpm -v检测
MacOs配置cnpm时报错
code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
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:
npm ERR! /Users/yx-0964/.npm/_logs/2022-06-01T05_37_22_094Z-debug.log
解决
1 permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
2 文件及其包含的目录的权限,或尝试运行npm犯错!再次以root/管理员的身份执行该命令。
会报错是因为执行命令没有获取管理员权限,只需要在原有的命令前面加上sudo获取权限,然后回车时候需要输入管理员密码即可。
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
检验一下 cnpm -v