7
votes

I attempted to do a sudo npm install -g appium on Mac OS 10.12.5.

I get this error:

info Chromedriver Install Installing Chromedriver version '2.30' for platform 'mac' and architecture '64'

info Chromedriver Install Opening temp file to write chromedriver_mac64 to...

Error: EACCES: permission denied, mkdir

'/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/2017820-44752-12jfqpb.z2hd'

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! [email protected] install: node install-npm.js npm ERR! Exit status 1 npm ERR!

this is not a dup question, as this install attempt was with sudo, as the other one was not.

4
Possible duplicate of npm throws error without sudoglennsl

4 Answers

42
votes

sudo npm install -g appium --unsafe-perm=true --allow-root

Worked for me

12
votes

you are using npm so you have to use

sudo npm install --unsafe-perm
In unsafe mode with every command you run
hopefully, it will help

0
votes

I reinstalled Node/NPM. Problem solved.

0
votes

The -g option means install globally. When packages are installed globally, EACCES permission errors can occur.

Consider setting up npm to operate globally without elevated permissions. See Resolving Permission Errors for more information.

Option 1

The best way to avoid permission issues is to reinstall NodeJS and npm using a node version manager.

1. Install 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.

2. To download and install the latest LTS release of NodeJS, run:

nvm install --lts

3. Set the newly installed NodeJS as the default environment:

nvm alias default lts/*

Option 2 (Does not apply for windows)

Change the owner of npm's directories to the current user:

sudo chown -R $(your_user) /usr/local/{lib/node_modules,bin,share}
sudo chown -R $(your_user) ~/.npm ~/.npmrc