'sudo npm install -g npm' 失败
'sudo npm install -g npm' fails
当我尝试通过 sudo npm install -g npm
更新 npm 时,Ubuntu 给出了错误
OS版本是Ubuntu,WSL下运行Version 20H2 (OS build 19042.746)
,我在老版本的Win10没遇到过这个问题
root@DESKTOP-D03G7FK:~# sudo npm update npm -g
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/yargs-parser
npm ERR! dest /usr/lib/node_modules/.staging/yargs-parser-b095ed45
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/yargs-parser' -> '/usr/lib/node_modules/.staging/yargs-parser-b095ed45'
npm ERR! [OperationalError: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/yargs-parser' -> '/usr/lib/node_modules/.staging/yargs-parser-b095ed45'] {
npm ERR! cause: [Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/yargs-parser' -> '/usr/lib/node_modules/.staging/yargs-parser-b095ed45'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/yargs-parser',
npm ERR! dest: '/usr/lib/node_modules/.staging/yargs-parser-b095ed45'
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/yargs-parser',
npm ERR! dest: '/usr/lib/node_modules/.staging/yargs-parser-b095ed45'
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-02-12T12_53_38_994Z-debug.log
问题没有解决,我换成WSL2了,因为WSL有Linux内核,所有问题都解决了,我觉得是WSL的bug。
过去 2 天我遇到了同样的问题,但很遗憾,我设法找到了解决方案。
首先,您需要安装 nvm
。您可以在此处找到最新版本并下载:nvm for windows
选择 nvm-setup.zip
然后继续并按照安装过程进行操作。
之后打开您的 windows 终端,然后尝试输入 nvm -v
以查看它是否已成功安装并拥有最新版本。
然后,如果一切正常,请输入 nvm install node
。
这会将您的节点更新到最新的可用版本。
使用 sudo /usr/bin/npm install -g npm
更新 npm...这将 bootstrap 使用使用 Ubuntu 的包管理器安装的旧版本 npm。
当你安装了多个版本的 npm 或 nodejs 时,启动时始终使用完整路径,否则你可能会在 运行.
时出错
当我尝试通过 sudo npm install -g npm
更新 npm 时,Ubuntu 给出了错误
OS版本是Ubuntu,WSL下运行Version 20H2 (OS build 19042.746)
,我在老版本的Win10没遇到过这个问题
root@DESKTOP-D03G7FK:~# sudo npm update npm -g
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/yargs-parser
npm ERR! dest /usr/lib/node_modules/.staging/yargs-parser-b095ed45
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/yargs-parser' -> '/usr/lib/node_modules/.staging/yargs-parser-b095ed45'
npm ERR! [OperationalError: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/yargs-parser' -> '/usr/lib/node_modules/.staging/yargs-parser-b095ed45'] {
npm ERR! cause: [Error: EACCES: permission denied, rename '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/yargs-parser' -> '/usr/lib/node_modules/.staging/yargs-parser-b095ed45'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/lib/node_modules/.staging/npm-18aca6f9/node_modules/yargs-parser',
npm ERR! dest: '/usr/lib/node_modules/.staging/yargs-parser-b095ed45'
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/yargs-parser',
npm ERR! dest: '/usr/lib/node_modules/.staging/yargs-parser-b095ed45'
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-02-12T12_53_38_994Z-debug.log
问题没有解决,我换成WSL2了,因为WSL有Linux内核,所有问题都解决了,我觉得是WSL的bug。
过去 2 天我遇到了同样的问题,但很遗憾,我设法找到了解决方案。
首先,您需要安装 nvm
。您可以在此处找到最新版本并下载:nvm for windows
选择 nvm-setup.zip
然后继续并按照安装过程进行操作。
之后打开您的 windows 终端,然后尝试输入 nvm -v
以查看它是否已成功安装并拥有最新版本。
然后,如果一切正常,请输入 nvm install node
。
这会将您的节点更新到最新的可用版本。
使用 sudo /usr/bin/npm install -g npm
更新 npm...这将 bootstrap 使用使用 Ubuntu 的包管理器安装的旧版本 npm。
当你安装了多个版本的 npm 或 nodejs 时,启动时始终使用完整路径,否则你可能会在 运行.
时出错