无法在Ubuntu中使用节点软件包管理器安装软件包 [英] Cannot install packages using node package manager in Ubuntu

查看:99
本文介绍了无法在Ubuntu中使用节点软件包管理器安装软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NodeJS解释器名称(node)已重命名为nodejs.这是自述文件. Debian说:

NodeJS interpreter name(node) on Ubuntu has been renamed to nodejs because of a name conflict with another package. Here's what the readme. Debian says:

Node.js解释器命令的上游名称为"node". 在Debian中,解释器命令已更改为"nodejs".

The upstream name for the Node.js interpreter command is "node". In Debian the interpreter command has been changed to "nodejs".

这样做是为了防止名称空间冲突:其他命令使用 在上游具有相同的名称,例如"node"中的ax25-node 包.

This was done to prevent a namespace collision: other commands use the same name in their upstream, such as ax25-node from the "node" package.

调用Node.js作为shell命令的脚本必须改为 使用"nodejs"命令.

Scripts calling Node.js as a shell command must be changed to instead use the "nodejs" command.

但是,使用nodejs会伪装使用npm安装软件包.软件包安装失败,并出现以下错误:

However, using nodejs mucks up installing packages using npm. Package installation fails with the following error:

sh: 1: node: not found
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian

我如何让npm理解系统上已经安装了nodejs,但解释器名称不同?

How do I make npm understand that nodejs is already installed on the system but the interpreter name is different?

推荐答案

TL; DR:

sudo apt-get install nodejs-legacy


首先让我澄清一下情况.在2012年夏季,Debian维护者决定重命名Node.js可执行文件,以防止某种名称空间与另一个软件包冲突.对于Debian技术委员会来说,这是非常艰难的决定,因为它破坏了向后兼容性.


First of all let me clarify the situation a bit. In summer 2012 Debian maintainers decided to rename Node.js executable to prevent some kind of namespace collision with another package. It was very hard decision for Debian Technical Committee, because it breaks backward compatibility.

以下是在Debian中发布的委员会决议草案的引文邮件列表:

The following is a quote from Committee resolution draft, published in Debian mailing list:

  1. 应将nodejs软件包更改为提供/usr/bin/nodejs,而不是/usr/bin/node.程序包应声明与以下内容的Breaks:关系 Debian中任何引用/usr/bin/node的软件包.

  1. The nodejs package shall be changed to provide /usr/bin/nodejs, not /usr/bin/node. The package should declare a Breaks: relationship with any packages in Debian that reference /usr/bin/node.

nodejs源程序包还应提供Priority优先级的nodejs-legacy二进制程序包:Extra,其中包含/usr/bin/node作为与之的符号链接. /usr/bin/nodejs.存档中的任何软件包都可能不依赖或不建议 nodejs-legacy程序包,仅为上游提供
兼容性.该软件包声明还应声明一个冲突: 与节点包的关系.

The nodejs source package shall also provide a nodejs-legacy binary package at Priority: extra that contains /usr/bin/node as a symlink to /usr/bin/nodejs. No package in the archive may depend on or recommend the nodejs-legacy package, which is provided solely for upstream
compatibility. This package declares shall also declare a Conflicts: relationship with the node package.

< ...>

第2段是OP问题的实际解决方案. OP应该尝试安装此软件包,而不要手动进行符号链接.这是Debian软件包索引网站中该软件包的链接.

Paragraph 2 is the actual solution for OP's issue. OP should try to install this package instead of doing symlink by hand. Here is a link to this package in Debian package index website.

可以使用sudo apt-get install nodejs-legacy安装.

我还没有发现有关NPM开发人员采用整件事的任何信息,但我认为npm软件包将在某个时候被修复,并且nodejs-legacy真正成为传统.

I have not found any information about adopting the whole thing by NPM developers, but I think npm package will be fixed on some point and nodejs-legacy become really legacy.

这篇关于无法在Ubuntu中使用节点软件包管理器安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆