Mac电脑使用:通过Mac终端安装淘宝镜像报错,提示无权限的解决方法

最近在开发过程中,遇到了给Mac电脑装淘宝镜像遇到的一个无权限问题,也就是Mac电脑的终端默认情况下打开的是普通用户模式,安装淘宝镜像需要打开管理员模式才行,所以在执行命令的时候不用管理员模式的话,就会提示无权限。

本篇博文就来分享一下解决安装淘宝镜像的时候提示无权限的方法,其实只要在执行安装淘宝镜像命令前面加上管理员权限就行了,具体的报错提示以及解决方法如下所示。

Mac电脑终端执行下载安装淘宝镜像命令:npm install -g cnpm --registry=https://registry.npm.taobao.org 之后的报错无权限的提示如下所示:

Mac-mini:~ Chen$ npm install -g cnpm --registry=https://registry.npm.taobao.org

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

npm ERR! 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! stack: "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/Chen/.npm/_logs/2020-01-11T01_02_02_782Z-debug.log

 

 

Mac电脑使用:通过Mac终端安装淘宝镜像报错,提示无权限的解决方法

 

上述问题的解决步骤:

使用这个命令:sudo npm install -g express-generator 也会有问题;

使用这个命令:sudo npm install -g cnpm --registry=https://registry.npm.taobao.org --verbose 就可以安装成功了。

 

 

Mac电脑使用:通过Mac终端安装淘宝镜像报错,提示无权限的解决方法

 

 

安装成功提示如下所示:

npm timing action:postinstall Completed in 219ms

npm verb unlock done using /Users/Chen/.npm/_locks/staging-3a08f84d.lock for /usr/local/lib/node_modules/.staging

npm timing stage:executeActions Completed in 10194ms

npm timing stage:rollbackFailedOptional Completed in 2ms

npm timing stage:runTopLevelLifecycles Completed in 19473ms

+ cnpm@6.1.1

added 681 packages from 942 contributors in 19.477s

npm verb exit [ 0, true ]

npm timing npm Completed in 20072ms

npm info ok

 

Mac电脑使用:通过Mac终端安装淘宝镜像报错,提示无权限的解决方法

上一篇:ubuntu 16.04 开机鼠标键盘失灵修复


下一篇:操作系统第2次实验报告:创建进程