在使用npm uninstall -g appium卸载appium的过程中报错
Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/appium' -> '/usr/local/lib/node_modules/.appium-cfBVovI6'
bash
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/appium
npm ERR! dest /usr/local/lib/node_modules/.appium-cfBVovI6
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/appium' -> '/usr/local/lib/node_modules/.appium-cfBVovI6'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/appium' -> '/usr/local/lib/node_modules/.appium-cfBVovI6'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/appium',
npm ERR! dest: '/usr/local/lib/node_modules/.appium-cfBVovI6'
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.
解决办法
1、首先检查谁拥有该目录
bash
ls -la /usr/local/lib/node_modules
它拒绝访问,因为 node_module 文件夹下的appium归 root 所有
因此需要通过将 root 更改为您的用户来更改此设置,但首先运行下面的命令来检查您当前的用户如何通过 OS X 中的命令行获取活动用户的名称?
id -un
或者whoami
然后更换所有者
bash
sudo chown -R [owner]:[owner] /usr/local/lib/node_modules
或者
bash
sudo chown -R ownerName: /usr/local/lib/node_modules
或者
bash
sudo chown -R $USER /usr/local/lib/node_modules