Версия, которая стоит у меня - 6.14.4
Вот что я пробовал:
1.
sudo npm install -g npm
Но когда я ввожу npm -v, то выходит 6.14.4
2.
npm install -g npm
В этом случае выходит ошибка:
npm WARN checkPermissions Missing write access to /usr/local/lib
npm WARN notsup Unsupported engine for npm@9.6.2: wanted: {"node":"^14.17.0 || ^16.13.0 || >=18.0.0"} (current: {"node":"10.19.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: npm@9.6.2
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib' }
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/chebak/.npm/_logs/2023-03-21T05_57_28_055Z-debug.log
А версия всё равно 6.14.4
3.
sudo npm update npm -g
Версия всё равно 6.14.4.
---------------------------------------
Решил эту проблему с помощью nvm.
Как его установить -
https://setiwik.ru/kak-ustanovit-nvm-na-ubuntu-22-04/