[英]npm install: Error: EACCES: permission denied, mkdir
I attempted to do a sudo npm install -g appium
on Mac OS 10.12.5.我试图在 Mac OS
sudo npm install -g appium
上执行sudo npm install -g appium
。
I get this error:我收到此错误:
info Chromedriver Install Installing Chromedriver version '2.30' for platform 'mac' and architecture '64'
信息 Chromedriver 安装 为平台“mac”和架构“64”安装 Chromedriver 版本“2.30”
info Chromedriver Install Opening temp file to write chromedriver_mac64 to...
信息 Chromedriver 安装正在打开临时文件以将 chromedriver_mac64 写入...
Error: EACCES: permission denied, mkdir
错误:EACCES:权限被拒绝,mkdir
'/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/2017820-44752-12jfqpb.z2hd'
'/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/2017820-44752-12jfqpb.z2hd'
npm ERR!
npm 错误! code ELIFECYCLE
代码生命周期
npm ERR!
npm 错误! errno 1
错误号 1
npm ERR!
npm 错误! appium-chromedriver@3.0.1 install:
node install-npm.js
npm ERR!appium-chromedriver@3.0.1 安装:
node install-npm.js
npm ERR! Exit status 1 npm ERR!退出状态 1 npm ERR!
this is not a dup question, as this install attempt was with sudo, as the other one was not.这不是重复问题,因为此安装尝试是使用 sudo 进行的,而另一个则不是。
sudo npm install -g appium --unsafe-perm=true --allow-root
须藤 npm install -g appium --unsafe-perm=true --allow-root
Worked for me为我工作
you are using npm so you have to use你正在使用 npm 所以你必须使用
sudo npm install --unsafe-perm须藤 npm install --unsafe-perm
In unsafe mode with every command you run在不安全模式下,您运行的每个命令
hopefully, it will help希望它会有所帮助
I reinstalled Node/NPM.我重新安装了 Node/NPM。 Problem solved.
问题解决了。
The -g
option means install globally . -g
选项表示全局安装。 When packages are installed globally , EACCES
permission errors can occur.全局安装软件包时,可能会发生
EACCES
权限错误。
Consider setting up npm to operate globally without elevated permissions.考虑将 npm 设置为在没有提升权限的情况下全局运行。 See Resolving Permission Errors for more information.
有关更多信息,请参阅解决权限错误。
Option 1选项 1
The best way to avoid permission issues is to reinstall NodeJS and npm using a node version manager.避免权限问题的最佳方法是使用节点版本管理器重新安装 NodeJS 和 npm。
1. Install nvm 1.安装nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
You can close and reopen the terminal ou just open another terminal and check if nvm is installed properly with this command: command -v nvm
.您可以关闭并重新打开终端,只需打开另一个终端并使用以下命令检查 nvm 是否正确安装:
command -v nvm
。
2. To download and install the latest LTS release of NodeJS, run: 2. 要下载并安装 NodeJS 的最新 LTS 版本,请运行:
nvm install --lts
3. Set the newly installed NodeJS as the default environment: 3、将新安装的NodeJS设置为默认环境:
nvm alias default lts/*
Option 2 (Does not apply for windows)选项 2 (不适用于 windows)
Change the owner of npm's directories to the current user:将 npm 目录的所有者更改为当前用户:
sudo chown -R $(your_user) /usr/local/{lib/node_modules,bin,share}
sudo chown -R $(your_user) ~/.npm ~/.npmrc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.