Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm install failing (Error: EACCES: permission denied, mkdir) #21

Closed
alexgig opened this issue Apr 6, 2017 · 53 comments
Closed

npm install failing (Error: EACCES: permission denied, mkdir) #21

alexgig opened this issue Apr 6, 2017 · 53 comments

Comments

@alexgig
Copy link

alexgig commented Apr 6, 2017

Hi,

I am having trouble installing this package globally. I run the following:

sudo npm install -g elm-github-install

and get the following:

npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
/usr/local/bin/elm-github-install -> /usr/local/lib/node_modules/elm-github-install/scripts/run.js
/usr/local/bin/elm-install -> /usr/local/lib/node_modules/elm-github-install/scripts/run.js

> elm-github-install@0.3.1 install /usr/local/lib/node_modules/elm-github-install
> node scripts/install.js

Downloading and extracting the binary from: https://github.com/gdotdesign/elm-github-install/releases/download/v0.3.1/elm-install-0.3.1-osx.tar.gz
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, mkdir '/Users/alexandre/.elm-install'
    at Error (native)
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "elm-github-install"
npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! elm-github-install@0.3.1 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the elm-github-install@0.3.1 install script 'node scripts/install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the elm-github-install package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs elm-github-install
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls elm-github-install
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/alexandre/Projects/elm-node/test/npm-debug.log

Thanks,
Alex

@samueller
Copy link

samueller commented Apr 21, 2017

Having the same issue on macOS Sierra. I manually ran mkdir '/Users/scott/.elm-install' as it said permission denied for that command. Then I manually ran mkdir '/Users/scott/.elm-install/elm-install-0.3.1-osx' for the same reason. Now I get the following error:

Error: EPERM: operation not permitted, utime '/Users/scott/.elm-install/elm-install-0.3.1-osx/'

I'm running the latest version of npm (v4.5.0) and I also ran the install with sudo.

@gdotdesign
Copy link
Owner

I probably won't be able to reproduce this because I don't have access to a mac. If anyone could debug this I would be grateful.

In the mean time there are other ways of installing:

@samueller
Copy link

It worked for me by not installing globally. I just took off the -g flag. Then I ran elm-github-install with node_modules/.bin/elm-github-install.

@rupertlssmith
Copy link

Not just Macs, I get the same issue on Linux:

sudo npm install elm-github-install@1.0.0 -g
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
/usr/local/bin/elm-github-install -> /usr/local/lib/node_modules/elm-github-install/scripts/run.js
/usr/local/bin/elm-install -> /usr/local/lib/node_modules/elm-github-install/scripts/run.js

> elm-github-install@1.0.0 install /usr/local/lib/node_modules/elm-github-install
> node scripts/install.js

Downloading and extracting the binary from: https://github.com/gdotdesign/elm-github-install/releases/download/v1.0.0/elm-install-1.0.0-linux-x86_64.tar.gz
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, mkdir '/root/.elm-install/elm-install-1.0.0-linux-x86_64'
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "elm-github-install@1.0.0" "-g"
npm ERR! node v7.10.0
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

@thienngho
Copy link

I got the same issue on Ubuntu


> elm-github-install@1.0.1 install /usr/local/lib/node_modules/elm-github-install
> node scripts/install.js

Downloading and extracting the binary from: https://github.com/gdotdesign/elm-github-install/releases/download/v1.0.1/elm-install-1.0.1-linux-x86_64.tar.gz
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, mkdir '/root/.elm-install/elm-install-1.0.1-linux-x86_64'
npm info lifecycle elm-github-install@1.0.1~install: Failed to exec install script
npm ERR! Linux 4.4.0-71-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "elm-github-install" "-g"
npm ERR! node v7.10.0
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR! elm-github-install@1.0.1 install: `node scripts/install.js`
npm ERR! Exit status 1```

@cscalfani
Copy link

cscalfani commented Jun 13, 2017

@samueller After I created the 2 directories manually, I had to change the owner of the 2nd directory with:

sudo chown nobody elm-install-1.0.1-osx/

Then it WORKS!

BTW, afterwards you need to change ownership back to you for all files (-R) otherwise it won't run:

sudo chown -R charles elm-install-1.0.1-osx/

Note: change charles to your user.

@dbulic
Copy link

dbulic commented Jun 25, 2017

On Ubuntu 16.04 I am getting the same thing when using

sudo npm i -g elm

However, yarn works well

sudo yarn global add elm

@on3iro
Copy link

on3iro commented Jul 26, 2017

Same problem, and also on ubuntu. The workaround with yarn @dbulic mentioned works, though.

@gdotdesign
Copy link
Owner

This PR #33 should fix this issue once released.

@rupertlssmith
Copy link

Muchos appreciated.

@gdotdesign
Copy link
Owner

Released as v1.2.0

If someone affected with this could test it out it would be appreciated 👍

@samueller
Copy link

v1.4.0 still causing an issue on my Mac:

Scotts-MacBook-Pro:learn scott$ sudo npm i elm-github-install -g
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
/usr/local/bin/elm-install -> /usr/local/lib/node_modules/elm-github-install/scripts/run.js
/usr/local/bin/elm-github-install -> /usr/local/lib/node_modules/elm-github-install/scripts/run.js

> elm-github-install@1.4.0 install /usr/local/lib/node_modules/elm-github-install
> node scripts/install.js

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/elm-github-install/scripts/dist-1.4.0'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! elm-github-install@1.4.0 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the elm-github-install@1.4.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@ColaKaii
Copy link

@cscalfani Thank you!!!!!!
This help me a lots!!!!!!!!!!!

@ghost
Copy link

ghost commented Sep 28, 2017

sudo npm i -g elm-github-install --unsafe-perm=true --allow-root

same for "just elm"

sudo npm i -g elm --unsafe-perm=true --allow-root

/related: npm/npm#17268

@gdotdesign
Copy link
Owner

Thank you! 🤗 I'll update the Readme to use that as a fallback.

@maksimluzik
Copy link

This is permission issue on the folder. For some reason subfolder permissions were changed from jenkins to root which caused the issue. sudo chown -R jenkins:jenkins foldername solved the issue.

@SmiffyKMc
Copy link

@maksimluzik I am having this issue trying to build an android sdk. I wrote what you said and it's still causing an issue. Can someone please give me a tip as I'm after spending 3 days at this and it's killing me oO.

My shell is:

source /etc/profile
set JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
set ANDROID_HOME=/Users/me/Library/Android/sdk
set PATH=%ANDROID_HOME%/platform-
tools:%ANDROID_HOME%/tools:%ANDROID_HOME%/tools/bin:%PATH%
npm install
bower install
ionic cordova build android

ERROR:

Error: EACCES: permission denied, open '/Users/me/Library/Android/sdk/tools/source.properties'

The file:

-rwxrwxrwx+  1 jenkins         jenkins        70 13 Dec  2016 source.properties

@maksimluzik
Copy link

@SmiffyKMc that looks weird issue indeed. Not sure whats up with that. If you are 100% sure that the path to that file is correct /Users/me/Library/Android/sdk/tools/source.properties then unfortunately don't know from your description what is the issue

@SmiffyKMc
Copy link

@maksimluzik ah shame, was hoping you'd know since your last comment was my issue. Sorry, my main issue is that I'm trying to build an Ionic Android App through Jenkins. I can build it perfectly fine on the terminal but Jenkins seems to be having issues with permissions. I made owner and group of the files from the folder that jenkins needs access to but it still gives a permission denied. Maybe if I did all this on a Docker image?

@agbottan
Copy link

agbottan commented Jan 13, 2018

I had the same kind of problem, with denied permissions. I'm using Linux Mint and, even with 'sudo', the permission to create folders was denied.
I achieved the complete installation opening a new terminal window with the root user.
My guess is that, even if we use 'sudo', npm can change it's user in the flow and loose the permissions granted by 'sudoing'.
And, I think that using the root terminal may be a security issue.

@GasCreature
Copy link

Still does not work. I'm using most recent Kali Linux.

@GasCreature
Copy link

@noformnocontent Your voodoo worked. You're a genius.

@rokf
Copy link

rokf commented Jan 25, 2018

@noformnocontent Thank you!

@gemantzu
Copy link

gemantzu commented Feb 6, 2018

@dbulic Thank you, it works on Solus as well.

@deepakchaula
Copy link

try this to install package...

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

@playmobilman
Copy link

@deepakchaula Proven it's working!! Thanks!

@dtonhofer
Copy link

dtonhofer commented Mar 2, 2018

@deepakchaula

Nah, now it's "ELOOP: too many symbolic links encountered, open '/usr/lib/node_modules/npm/node_modules.bundled/tar/node_modules/minizlib/package.json.2876729455'"
and rightly so because "/usr/lib/node_modules/npm/" is actually a symlink to itself...

(Why is installation a problem? It's been done since more than 20 years now. ☠☠☠!!)

@jameslaydigital
Copy link

Yup, had this problem on Debian. Fixed like so:

npm install elm
mv -vi node_modules/* /usr/local/lib/node_modules/

Afterwards I was able to run elm.

@melindangas
Copy link

@deepakchaula Thank you it worked!

@TongDaDa
Copy link

TongDaDa commented Jun 4, 2018

@deepakchaula why sudo npm install --unsafe-perm=true --allow-root ?

It does, however, there are no more questions

@kane0409
Copy link

if you install a package that you have the package name, you run 'sudo npm install package_name --unsafe-perm=true --allow-root'. If you don't know which package you missing, just run 'sudo npm install --unsafe-perm=true --allow-root' in your project folder that has node_modules.

@Ewebstech
Copy link

@deepakchaula. Works fine. Thanks

@miguelortega20
Copy link

sd

@rohitlabhe
Copy link

@deepakchaula Thanks for command
sudo npm install --unsafe-perm=true --allow-root
It is working fine for Ubuntu.

@shov
Copy link

shov commented Oct 24, 2018

If you have no root access,
HOME=./ npm i

@darrencole
Copy link

Thank you @deepakchaula!

@c-yyy
Copy link

c-yyy commented Apr 1, 2019

sudo npm i -g elm-github-install
or
sudo yarn global add elm-github-install

@freddy-daniel
Copy link

Still getting this issue on my mac

mac10s-Mac-mini:desktop-app mac10$ sudo npm install --cache /tmp/empty-cache
Password:

> electron@4.1.4 postinstall /Users/mac10/Documents/freddy/desktop-app/node_modules/electron
> node install.js

Downloading tmp-3049-1-SHASUMS256.txt-4.1.4
[============================================>] 100.0% of 4.74 kB (4.74 kB/s)
/Users/mac10/Documents/freddy/desktop-app/node_modules/electron/install.js:49
  throw err
  ^

Error: EACCES: permission denied, mkdir '/Users/mac10/Documents/freddy/desktop-app/node_modules/electron/dist'
npm WARN app@4.0.6 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@4.1.4 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the electron@4.1.4 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/empty-cache/_logs/2019-04-09T11_27_33_000Z-debug.log

@darrencole
Copy link

@freddy_daniel, try adding unsafe-perm=true --allow-root to the install command if you're sure that what you are installing is safe.

@freddy-daniel
Copy link

I have fixed this issue by sudo chmod -R 777 on my project folder
And run npm install --cache /tmp/empty-cache without sudo now it's works fine

@doonfrs
Copy link

doonfrs commented May 3, 2019

try this to install package...

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

Worked for me, Thank you!

@aliraza-dev
Copy link

@ghost's solution works for me, even whilst installing corvova-res globally. Thanks, Not all hero's wear capes.

@TraceLD
Copy link

TraceLD commented Jul 25, 2019

sudo chown -R $USER ~/.npm worked for me

@MystesofEternity
Copy link

@deepakchaula You're a real life saver! Thank you!

@RileySeaburg
Copy link

How does changing the owner of the directory make it work?
Is this an npm bug?

Solution worked for me but this is strange!

@abinhho
Copy link

abinhho commented Nov 29, 2019

Add more param like that --unsafe-perm=true --allow-root

sudo npm i --save [packagename] --unsafe-perm=true --allow-root

@rishardcarranza
Copy link

rishardcarranza commented Dec 4, 2019

try this to install package...

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

This solution works well for me, thanks @deepakchaula 👍

@vitorpiovezam
Copy link

To install globally, without need --unsafe-perm=true --allow-root in Elementary Os (ubuntu based) this work for me

npm config set prefix /usr/local
mkdir /usr/local/lib/node_modules
sudo chmod +777 /usr/local/lib/node_modules

Now you can install any package globally

npm i -g <package-name>

@anupsalpe
Copy link

I have deleted the 'node_modules/' folder and install npm package again. npm install
And it worked :)

@JacoJeco
Copy link

try this to install package...

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

It works ! thnx !

@kulketan
Copy link

Add more param like that --unsafe-perm=true --allow-root

sudo npm i --save [packagename] --unsafe-perm=true --allow-root

Thanks.. It worked for me on Ubuntu 19.10.

@andrade-bruno
Copy link

try this to install package...

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

This solved my problem on Ubuntu 20.04 with non-root user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests