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

Unable to update npm using npm i -g npm #224

Open
baleeds opened this issue Mar 31, 2021 · 8 comments
Open

Unable to update npm using npm i -g npm #224

baleeds opened this issue Mar 31, 2021 · 8 comments

Comments

@baleeds
Copy link

baleeds commented Mar 31, 2021

Thanks for all the hard work on this plugin, it's been great for me!

I have an issue that I believe is partially related to WSL1 with Ubuntu 18.04. I'm unable to update npm using the built-in upgrade method of npm i -g npm.

I get the following stack trace:

npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/npm-80a480ea/node_modules/string-width
npm ERR! dest /home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/string-width-35f27461
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/npm-80a480ea/node_modules/string-width' -> '/home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/string-width-35f27461'
npm ERR!  [OperationalError: EACCES: permission denied, rename '/home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/npm-80a480ea/node_modules/string-width' -> '/home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/string-width-35f27461'] {
npm ERR!   cause: [Error: EACCES: permission denied, rename '/home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/npm-80a480ea/node_modules/string-width' -> '/home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/string-width-35f27461'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'rename',
npm ERR!     path: '/home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/npm-80a480ea/node_modules/string-width',
npm ERR!     dest: '/home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/string-width-35f27461'
npm ERR!   },
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/npm-80a480ea/node_modules/string-width',
npm ERR!   dest: '/home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/string-width-35f27461'
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/bleeds/.npm/_logs/2021-03-31T18_46_57_862Z-debug.log

I also have Ubuntu 20 running on WSL2 and npm updates fine using asdf in that environment, both running the same nodejs version.

Does anyone have any ideas on what could be happening? Obviously, there is an issue with renaming the files. I did try restarting my computer and running only the WSL1 terminal.

@augustobmoura
Copy link
Member

augustobmoura commented Apr 7, 2021

Have you tried installing node and npm via the official installation method? The error still persists in that case?
Maybe the error is not related to asdf by itself, looking at the logs it looks like a permission error
I don't have a windows machine closer so I can't debug it

@augustobmoura
Copy link
Member

Also, can you run the command namei -l /home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/ and paste the output here? So that we could check if any permission is off

@baleeds
Copy link
Author

baleeds commented Apr 27, 2021

Sorry for the delay.

Also, can you run the command namei -l /home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/ and paste the output here? So that we could check if any permission is off

f: /home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/
drwxr-xr-x root   root   /
drwxr-xr-x root   root   home
drwxr-xr-x bleeds bleeds bleeds
drwxr-xr-x bleeds bleeds .asdf
drwxr-xr-x bleeds bleeds installs
drwxr-xr-x bleeds bleeds nodejs
drwxr-xr-x bleeds bleeds 14.16.0
drwxr-xr-x bleeds bleeds .npm
drwxr-xr-x bleeds bleeds lib
drwxr-xr-x bleeds bleeds node_modules
                         .staging - No such file or directory

@baleeds
Copy link
Author

baleeds commented Apr 27, 2021

I was able to install node using apt package manager with no issues.

apt list --installed | grep node gives me this:


WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

nodejs/bionic-updates,now 8.10.0~dfsg-2ubuntu0.4 amd64 [installed]
nodejs-doc/bionic-updates,now 8.10.0~dfsg-2ubuntu0.4 all [installed,automatic]

I don't really understand how to install node using the official binaries. Seems like it would be a simple extraction to a directory of my choice, and an addition to the path in my .zshrc?

@augustobmoura
Copy link
Member

augustobmoura commented May 1, 2021

f: /home/bleeds/.asdf/installs/nodejs/14.16.0/.npm/lib/node_modules/.staging/
drwxr-xr-x root   root   /
drwxr-xr-x root   root   home
drwxr-xr-x bleeds bleeds bleeds
drwxr-xr-x bleeds bleeds .asdf
drwxr-xr-x bleeds bleeds installs
drwxr-xr-x bleeds bleeds nodejs
drwxr-xr-x bleeds bleeds 14.16.0
drwxr-xr-x bleeds bleeds .npm
drwxr-xr-x bleeds bleeds lib
drwxr-xr-x bleeds bleeds node_modules
                         .staging - No such file or directory

Seems like the permissions are all right. I don't see anything strange.

I don't really understand how to install node using the official binaries. Seems like it would be a simple extraction to a directory of my choice, and an addition to the path in my .zshrc?

Yes, pretty much

It's weird because the permission denied is for a rename, not a file created, not a delete. I searched really quick about this on google and found this that points to an issue in WSL that should be fixed in WSL2. Can you try it in a WSL2 environment?

We don't actively support WSL, but it would be rather nice to have it working

@jlumbroso
Copy link

jlumbroso commented May 26, 2021

I just installed Node.js with asdf on macOS Big Sur, and tried to update npm that comes installed:

[...]
npm notice New minor version of npm available! 7.13.0 -> 7.14.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.14.0
npm notice Run npm install -g npm@7.14.0 to update!
npm notice

» which npm
/Users/jlumbroso/.asdf/shims/npm

» npm --version
7.13.0

» npm install -g npm@7.14.0
npm notice
npm notice New minor version of npm available! 7.13.0 -> 7.14.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.14.0
npm notice Run npm install -g npm@7.14.0 to update!
npm notice
npm ERR! code EEXIST
npm ERR! path /Users/jlumbroso/.asdf/installs/nodejs/16.2.0/.npm/bin/npx
npm ERR! EEXIST: file already exists
npm ERR! File exists: /Users/jlumbroso/.asdf/installs/nodejs/16.2.0/.npm/bin/npx
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jlumbroso/.npm/_logs/2021-05-26T04_55_22_211Z-debug.log

If npm i -g npm is not the right way to update npm, what is the right way?

@vraravam
Copy link

I am on macos Big Sur, but I was able to successfully upgrade/install npm from 6.x to 7.x (node is installed using asdf-nodejs plugin)

@baleeds
Copy link
Author

baleeds commented Oct 18, 2021

@augustobmoura Sorry for falling off of this.

Can you try it on a WSL2 environment?

I have tried it in WSL 2 (though it's Ubuntu 20) and it's working great. Updates still give the same issue. The linked issue from WSL could certainly be relevant, though I'm not using VSCode or really running anything from WSL at the time the failures happen. I'm basically using it for git at this point.

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

4 participants