“尝试覆盖‘/usr/share/man/man1/node.1.gz’,它也位于软件包 nodejs-legacy 0.10.25~dfsg2-2ubuntu1 中”

“尝试覆盖‘/usr/share/man/man1/node.1.gz’,它也位于软件包 nodejs-legacy 0.10.25~dfsg2-2ubuntu1 中”

我正在尝试安装 nodejs,但一直失败。附件是日志

$ sudo apt-get install nodejs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libc-ares2 libv8-3.14.5
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  rlwrap
The following NEW packages will be installed:
  rlwrap
The following packages will be upgraded:
  nodejs
1 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 0 B/4,391 kB of archives.
After this operation, 14.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package rlwrap.
(Reading database ... 263979 files and directories currently installed.)
Preparing to unpack .../rlwrap_0.37-5_amd64.deb ...
Unpacking rlwrap (0.37-5) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_0.10.31-1chl1~trusty1_amd64.deb ...
Unpacking nodejs (0.10.31-1chl1~trusty1) over (0.10.25~dfsg2-2ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_0.10.31-1chl1~trusty1_amd64.deb (--unpack):
 trying to overwrite '/usr/share/man/man1/node.1.gz', which is also in package nodejs-legacy 0.10.25~dfsg2-2ubuntu1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Processing triggers for man-db (2.6.7.1-1) ...
Errors were encountered while processing:
 /var/cache/apt/archives/nodejs_0.10.31-1chl1~trusty1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

可能修复安装

正如查尔斯在评论中所说,我会尝试运行sudo apt-get updatesudo apt-get upgrade。您可能还想运行sudo apt-get autoremove以删除不再需要的软件包。

错误中提到了该nodejs-legacy软件包。如果您曾经安装过该软件包,则可能需要将其删除。

在 Ubuntu 上安装 Node 的更好方法

除非你打算将你的计算机用作生产服务器,否则我强烈建议你使用NVM 工具。从存储库安装需要您使用sudo,这会导致尝试安装 Node 模块时出现权限混乱使用 NPM。

另外,NVM 允许您安装多个版本的 Node,并且即使官方存储库落后,它也可以让您的 Node 副本保持最新。

获取最新的 NVM 副本

curl https://raw.githubusercontent.com/creationix/nvm/v0.15.0/install.sh | bash

告诉你的 shell 使用nvm

source ~/.nvm/nvm.sh

然后安装一个node版本

nvm install 0.10

并告诉 nvm 你想使用哪个版本的 Node

nvm use 0.10

答案2

我忘记做的一件事是清除以前的安装并重新安装。我使用以下命令删除了以前的安装

sudo apt-get purge nodejs-legacy nodejs

sudo apt-get install nodejs

重新安装nodejs。

链接SO答案对我有帮助

相关内容