Как обновить npm в WSL Ubuntu без ошибок?

У меня стоит NPM версии 6.14.10. Хочу её обновить. Использую подсистему Ubuntu 20.
При запуске команды sudo npm install -g npm выдаёт следующую ошибку:

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

Я понял что проблема в каких то правах, но это же странно, ведь я использовал sudo.
Подскажите пожалуйста как это можно решить?
  • Вопрос задан
  • 176 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы