Skip to content

npm package fails to install "npm ERR! Error: EACCES: permission denied" #14

@pallatee

Description

@pallatee

While trying to install a packge with npm (for example lodash) it fails with error message:

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "lodash"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path /root/test/node_modules/.staging/lodash-9a2aabe2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash'
npm ERR!     at Error (native)
npm ERR!  [Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash']
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/test/npm-debug.log

I have tried to install it both with and without starting bash in administrator mode.

Activity

borovaka

borovaka commented on Apr 7, 2016

@borovaka

There is another wired thing about npm. When I try to install gulp globally I get:

Error: could not get uid/gid
net.js:135
    this._handle.open(options.fd);
                 ^

Error: EINVAL: invalid argument, uv_pipe_open
    at Error (native)
    at new Socket (net.js:135:18)
    at createWritableStdioStream (internal/process/stdio.js:142:16)
    at process.stdout (internal/process/stdio.js:10:14)
    at console.js:99:37
    at NativeModule.compile (node.js:395:5)
    at Function.NativeModule.require (node.js:340:18)
    at node.js:223:27
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/uid-number/get-uid-gid.js:16:1)
    at Module._compile (module.js:413:34)

    at /usr/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
    at ChildProcess.exithandler (child_process.js:209:5)
    at emitTwo (events.js:100:13)
    at ChildProcess.emit (events.js:185:7)
    at maybeClose (internal/child_process.js:850:16)
    at Socket.<anonymous> (internal/child_process.js:323:11)
    at emitOne (events.js:90:13)
    at Socket.emit (events.js:182:7)
    at Pipe._onclose (net.js:475:12)
jamesscholeyweb

jamesscholeyweb commented on Apr 7, 2016

@jamesscholeyweb

Same here. In fact if I try to update npm update -g npm@latest it attempts to copy lodash to the staging directory then throws the errror. Following this subsequent attempts to use npm are broken because it can no longer find lodash.

IMPORTANT

This really should be of utmost importance to the team. I for one was very excited and love how everything else works, but as you are adding this feature to windows with the intention of bringing web developers back to windows this needs fixing ASAP. This alone will stop me switching back to windows for web development and I'm sure it will be the same for many. It defeats the purpose of switching for me. Please please please fix.

jgchristopher

jgchristopher commented on Apr 8, 2016

@jgchristopher

@borovaka you can fix that error by allowing unsafe perms

npm config set unsafe-perm=true

jamesscholeyweb

jamesscholeyweb commented on Apr 8, 2016

@jamesscholeyweb

Already tried. It bypasses the error but it still doesn't work. You will
get a permissions access error still or at least I did.

On Friday, April 8, 2016, John Christopher notifications@github.com wrote:

@borovaka https://github.com/borovaka you can fix that error by
allowing unsafe perms

npm config set unsafe-perm=true


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#14 (comment)

jgchristopher

jgchristopher commented on Apr 8, 2016

@jgchristopher

@jamesscholeyweb right, I was able to get to your error after setting those perms. Otherwise I wasn't able to do anything.

jgchristopher

jgchristopher commented on Apr 8, 2016

@jgchristopher

This seems to be the underlying issue.

root@localhost:/usr/lib/node_modules/.staging# rename /usr/lib/node_modules/.staging/lodash-24c8c2f4 /usr/lib/node_modules/ember-cli/node_modules/babel-core/node_modules/lodash Bareword found where operator expected at (eval 1) line 1, near "24c8c2f4" (Missing operator before c8c2f4?) Unknown regexp modifier "/b" at (eval 1) line 1, at end of line syntax error at (eval 1) line 1, near "/."

Sparticuz

Sparticuz commented on Apr 8, 2016

@Sparticuz

Related: MicrosoftDocs/WSL#26

It seems to be an issue with symlinks

jbaribeault

jbaribeault commented on Apr 8, 2016

@jbaribeault

Confirmed - this is totally related to the symlink issue.

jamespacileo

jamespacileo commented on Apr 11, 2016

@jamespacileo

Same here with

npm install typescript

Here's the output

npm WARN enoent ENOENT: no such file or directory, open '/root/package.json'
npm WARN root No description
npm WARN root No repository field.
npm WARN root No README data
npm WARN root No license field.
npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "typescript" "gulp" "tsd"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path /root/node_modules/.staging/ansi-regex-0de81b15
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename '/root/node_modules/.staging/ansi-regex-0de81b15' -> '/root/node_modules/ansi-regex'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/root/node_modules/.staging/ansi-regex-0de81b15' -> '/root/node_modules/ansi-regex'
npm ERR!     at Error (native)
npm ERR!  [Error: EACCES: permission denied, rename '/root/node_modules/.staging/ansi-regex-0de81b15' -> '/root/node_modules/ansi-regex']
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/npm-debug.log
russalex

russalex commented on Apr 12, 2016

@russalex
Contributor

This looks a lot like #3. We can keep the conversation going on there.

What I can say right now is that things are getting better (at least in non-mnt directories.). On my dev box I see:

russ@RUSSALEX-DESK:~/tmp$ npm list
/home/russ/tmp
├── acorn@3.0.4
├─┬ gulp@3.9.1
│ ├── archy@1.0.0
│ ├─┬ chalk@1.1.3
│ │ ├── ansi-styles@2.2.1
│ │ ├── escape-string-regexp@1.0.5
│ │ ├─┬ has-ansi@2.0.0
│ │ │ └── ansi-regex@2.0.0
│ │ ├─┬ strip-ansi@3.0.1
│ │ │ └── ansi-regex@2.0.0
│ │ └── supports-color@2.0.0
│ ├── deprecated@0.0.1
│ ├─┬ gulp-util@3.0.7
│ │ ├── array-differ@1.0.0

It goes on from there. I should point out that I have not tried to actually use any of these, I have only installed them.

The team is hard at work getting stuff up and running. Npm is one of those things we're looking at now.

russalex

russalex commented on Apr 14, 2016

@russalex
Contributor

Full disclosure here. Doing a little more testing on our internal build and finding that doing an "npm -g install " still throws the uv_pipe_open error, even when in ~/tmp.

We have someone looking into it.

188 remaining items

jimbethancourt

jimbethancourt commented on Apr 5, 2022

@jimbethancourt

If you're using VS Code and find yourself getting this error message, close VS Code, run the desired command, and restart VS Code, as indicated in https://stackoverflow.com/questions/60853873/eaccess-error-when-installing-packages-on-wsl

gifflet

gifflet commented on May 11, 2022

@gifflet

If you installed node from apt-get, uninstall it completely and install it from NVM (Node Version Manager)

Uninstalling node (Ubuntu)

sudo apt-get purge --auto-remove nodejs

Update apt indexes

sudo apt update && sudo apt upgrade

Install NVM

sudo apt-get install -y curl \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash \
&& source ~/.bashrc

Finally, install node and npm

nvm install --lts
tinarooot

tinarooot commented on May 11, 2022

@tinarooot
Jahongirhacking

Jahongirhacking commented on Jul 19, 2023

@Jahongirhacking

@borovaka you can fix that error by allowing unsafe perms

npm config set unsafe-perm=true

it says:

npm ERR! `unsafe-perm` is not a valid npm option

npm ERR! A complete log of this run can be found in:
npm ERR! `path`    
tinarooot

tinarooot commented on Jul 19, 2023

@tinarooot
Jahongirhacking

Jahongirhacking commented on Jul 19, 2023

@Jahongirhacking

If you installed node from apt-get, uninstall it completely and install it from NVM (Node Version Manager)

Uninstalling node (Ubuntu)

sudo apt-get purge --auto-remove nodejs

Update apt indexes

sudo apt update && sudo apt upgrade

Install NVM

sudo apt-get install -y curl \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash \
&& source ~/.bashrc

Finally, install node and npm

nvm install --lts

Thanks it worked

PttRulez

PttRulez commented on Oct 8, 2023

@PttRulez

I have fixed my problem on mac by
sudo chown -R 501:20 "/Users/<my_username>/.npm"

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jgchristopher@ohcibi@AlexHayton@parkerault@allain

        Issue actions

          npm package fails to install "npm ERR! Error: EACCES: permission denied" · Issue #14 · microsoft/WSL