【问题标题】:apt- get command error while installing nodejs安装nodejs时apt-get命令错误
【发布时间】:2015-05-21 01:23:02
【问题描述】:

我尝试使用 apt-get install 安装 nodejs,但出现以下错误

设置 spamassassin (3.4.0-6) ... 错误:需要 gpg 但未找到!不建议这样做,但您可以使用带有 --no-gpg 的“sa-update”来跳过验证。 dpkg: 错误处理包 spamassassin (--configure): 子进程安装后安装脚本返回错误退出状态 2 dpkg:依赖问题阻止配置 sa-compile: sa-compile 依赖于 spamassassin (>= 3.3.2-8);然而: 软件包 spamassassin 尚未配置。

dpkg: 错误处理包 sa-compile (--configure): 依赖性问题 - 未配置 没有写入任何 aport 报告,因为错误消息表明它是先前失败的后续错误。 处理时遇到错误: 刺客 sa编译 E: 子进程/usr/bin/dpkg返回错误码(1)

在此之后它终止。 如何解决?

【问题讨论】:

  • 你输入的完整的 apt-get 命令是什么?
  • spamassassin 不应为 nodejs 软件包安装。

标签: node.js ubuntu terminal apt-get


【解决方案1】:

所以,我在构建用于安装 node.js 的系统的前几次构建系统时使用了 apt-get,但我很快就放弃了它。能够只使用一行命令是很好和干净的,但是 apt 存储库不会经常更新,然后您会链接到他们选择的版本,而不是您想要或已经测试过的版本。

我转而使用预编译的 node.js 可执行文件(在 Ubuntu 12.04 上使用节点 0.8.21)。为此,我在将 http://nodejs.org/dist/v0.8.21/node-v0.8.21-linux-x64.tar.gz 的 Joyent 文件下载到 /home/username/Desktop/node-v08.21-linux-x64.tar.gz 后,使用 sudo 从 shell 脚本或命令行运行以下命令:

# untar the tar file to the directory /usr/local
tar -xvf /home/username/Desktop/node-v0.8.21-linux-x64.tar.gz -C /usr/local

# now create symbolic link in the /usr/local directory
ln -s /usr/local/node-v0.8.21-linux-x64/bin/node /usr/local/bin/node
ln -s /usr/local/node-v0.8.21-linux-x64/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm

#now make the directory to hold the node modules npm and set permissions
mkdir -p /usr/local/lib/node_modules
chmod 755 /usr/local/lib/node_modules

如果您在需要从头开始编译的系统上,可以从 Joyent 的 http://nodejs.org/dist/v0.8.21/node-v0.8.21.tar.gz 下载源代码,然后从终端运行以下命令或使用 sudo 运行的脚本来编译和部署节点:

#install things we need to install node
DEBIAN_FRONTEND=noninteractive apt-get install -y  build-essential python libssl-dev

#create and move into directory to do the install from
cd /home/username
mkdir nodeInstallDirectory
cd nodeInstallDirectory

#copy the tarred install file out for node
cp /home/username/Desktop/node-v0.8.21.tar.gz /home/username/nodeInstallDirectory/node-v0.8.21.tar.gz

#untar, and move into directory for node code
tar -xvf node-v0.8.21.tar.gz
cd node-v0.8.21

#these next three lines do the install itself
./configure
make -j 5
make install

这些说明应该也适用于更高或更早的 Node.js 版本。

【讨论】: