V
V
Vechkov Alexander2021-06-03 01:10:38
ubuntu
Vechkov Alexander, 2021-06-03 01:10:38

How to update npm in WSL Ubuntu without errors?

I have NPM version 6.14.10. I want to update it. I am using the Ubuntu 20 subsystem.
When I run the command, sudo npm install -g npmI get the following error:

npm ERR! code EACCES   
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width
npm ERR! dest /usr/lib/node_modules/.staging/string-width-5ef4a6e1
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width' -> '/usr/lib/node_modules/.staging/string-width-5ef4a6e1'
npm ERR!  [OperationalError: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width' -> '/usr/lib/node_modules/.staging/string-width-5ef4a6e1'] {
npm ERR!   cause: [Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width' -> '/usr/lib/node_modules/.staging/string-width-5ef4a6e1'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'rename',
npm ERR!     path: '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width',
npm ERR!     dest: '/usr/lib/node_modules/.staging/string-width-5ef4a6e1'
npm ERR!   },
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/string-width',
npm ERR!   dest: '/usr/lib/node_modules/.staging/string-width-5ef4a6e1'
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!     /root/.npm/_logs/2021-06-02T22_01_18_473Z-debug.log

I realized that the problem is in some kind of rights, but this is strange, because I used sudo .
Please tell me how this can be solved?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question