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

[BUG] Error EACCES -13 when using npm globally #1001

Closed
MithicSpirit opened this issue Mar 10, 2020 · 8 comments
Closed

[BUG] Error EACCES -13 when using npm globally #1001

MithicSpirit opened this issue Mar 10, 2020 · 8 comments
Labels
Bug thing that needs fixing

Comments

@MithicSpirit
Copy link

What / Why

I get an EACCES -13 error sometimes (more below) when using npm globally

When

Whenever I run one of the following:

  • npm -g upgrade
  • npm -g install npm

Where

npm v6.13.4 on node v12.16.1, installed with nvm, using Ubuntu 18.04.4 with WSL.

How

Current Behavior

Running either npm -g upgrade or npm -g install npm gives the following error:

$ npm -g upgrade
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/npm-d9b9c5ef/node_modules/yargs
npm ERR! dest /home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/yargs-b6502a51
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/npm-d9b9c5ef/node_modules/yargs' -> '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/yargs-b6502a51'
npm ERR!  [OperationalError: EACCES: permission denied, rename '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/npm-d9b9c5ef/node_modules/yargs' -> '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/yargs-b6502a51'] {
npm ERR!   cause: [Error: EACCES: permission denied, rename '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/npm-d9b9c5ef/node_modules/yargs' -> '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/yargs-b6502a51'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'rename',
npm ERR!     path: '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/npm-d9b9c5ef/node_modules/yargs',
npm ERR!     dest: '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/yargs-b6502a51'
npm ERR!   },
npm ERR!   stack: "Error: EACCES: permission denied, rename '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/npm-d9b9c5ef/node_modules/yargs' -> '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/yargs-b6502a51'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/npm-d9b9c5ef/node_modules/yargs',
npm ERR!   dest: '/home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/.staging/yargs-b6502a51'
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/mithic/.npm/_logs/2020-03-09T18_06_31_294Z-debug.log

Steps to Reproduce

Run npm -g upgrade or npm -g install npm

Expected Behavior

npm -g upgrade should attempt to update all globally installed packages to the latest version.
npm -g install npm should attempt to install the latest version of npm

@ljharb
Copy link
Contributor

ljharb commented Mar 10, 2020

Given that you're using nvm, that suggests that the permissions aren't right on $NVM_DIR. Can you make sure that mithic is the owner of every file, recursive, inside that directory?

@MithicSpirit
Copy link
Author

I believe so. $ find "$NVM_DIR" ! -user "mithic" did not return anything.

@ljharb
Copy link
Contributor

ljharb commented Mar 10, 2020

Hmm, that checks ownership; what about -writable?

@MithicSpirit
Copy link
Author

MithicSpirit commented Mar 10, 2020

Only two seem to not be writable:

$ find "$NVM_DIR" ! -writable
/home/mithic/.nvm/.git/objects/pack/pack-c69cf0d0b58b9bd8c5b179abd3da49e09356afe5.idx
/home/mithic/.nvm/.git/objects/pack/pack-c69cf0d0b58b9bd8c5b179abd3da49e09356afe5.pack

should I change the permissions on them?

@ljharb
Copy link
Contributor

ljharb commented Mar 10, 2020

nah, that's inside the nvm git repo, and wouldn't be related to this problem.

If you cd into /home/mithic/.nvm/versions/node/v12.16.1/lib/node_modules/, and manually check the permissions of . and the files in there, those also make sense?

@MithicSpirit
Copy link
Author

Yes, I own and have write permission for all of them.

@darcyclarke darcyclarke added the Bug thing that needs fixing label Oct 30, 2020
@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

1 similar comment
@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing
Projects
None yet
Development

No branches or pull requests

3 participants