asdf-nodejs icon indicating copy to clipboard operation
asdf-nodejs copied to clipboard

Unable to update npm using `npm i -g npm`

Open baleeds opened this issue 3 years ago • 8 comments

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.

baleeds avatar Mar 31 '21 18:03 baleeds

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 avatar Apr 07 '21 16:04 augustobmoura

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

augustobmoura avatar Apr 07 '21 16:04 augustobmoura

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 avatar Apr 27 '21 20:04 baleeds

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?

baleeds avatar Apr 27 '21 20:04 baleeds

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

augustobmoura avatar May 01 '21 22:05 augustobmoura

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 [email protected] to update!
npm notice

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

» npm --version
7.13.0

» npm install -g [email protected]
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 [email protected] 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?

jlumbroso avatar May 26 '21 04:05 jlumbroso

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)

vraravam avatar Oct 16 '21 02:10 vraravam

@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.

baleeds avatar Oct 18 '21 20:10 baleeds