“试图覆盖'/usr/share/man/man1/node.1.gz',它也在nodejs-legacy 0.10.25〜dfsg2-2ubuntu1软件包中”


9

我正在尝试安装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)

你能运行sudo apt-get updatesudo apt-get upgrade
查尔斯·格林

@CharlesGreen我可以使它工作。我已经回答了我的问题。
Shash 2014年

Answers:


10

潜在地修复安装

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

该错误提到了nodejs-legacy软件包。如果已经安装过,则可能要删除它。

在Ubuntu上安装Node的更好方法

除非你正在使用您的计算机作为一个生产服务器的规划,我强烈建议使用安装Node.js的NVM工具。从存储库安装需要您使用sudo,这会在您尝试使用NPM 安装Node模块时导致混乱的权限

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

获取NVM的最新副本

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

告诉您的外壳使用 nvm

source ~/.nvm/nvm.sh

然后安装节点版本

nvm install 0.10

并告诉nvm您要使用哪个版本的Node

nvm use 0.10

1
这次真是万分感谢。告诉我有关nvm的真正帮助。我已经厌倦了与权限斗争。
Chev

您也可以通过更新〜/ .npmrc中的前缀路径来解决权限问题,以便指向您的主目录。
2015年

8

我错过的一件事是清除先前的安装并重新安装。我使用以下命令删除了先前的安装

sudo apt-get purge nodejs-legacy nodejs

sudo apt-get install nodejs

重新安装nodejs。

链接对我有帮助的SO答案


啊,在我完成打字之前,您已经弄清楚了!:)不过,我仍然建议您查看NVM,这样您就可以避免sudo npm install每次想使用npm安装模块时都这样做。
Michael Martin-Smucker 2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.