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

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

问题描述

由于与另一个包的名称冲突,Ubuntu 上的

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

<块引用>

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

这样做是为了防止命名空间冲突:其他命令使用在它们的上游同名,例如来自节点"的 ax25-node包.

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

然而,使用 nodejs 会破坏使用 npm 安装软件包.软件包安装失败并出现以下错误:

<块引用>

sh: 1: 节点:未找到npm WARN 此失败可能是由于使用了旧版二进制节点"npm WARN 更多解释请阅读/usr/share/doc/nodejs/README.Debian

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

解决方案

TL;DR:

sudo apt-get install nodejs-legacy

<小时>

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

以下是委员会决议草案的引述,发表于 Debian 邮件列表:

<块引用>

  1. nodejs 包应该改为提供/usr/bin/nodejs,而不是/usr/bin/node.包应该声明一个 Breaks: 关系Debian 中任何引用/usr/bin/node 的软件包.

  2. nodejs 源包还应在 Priority: extra 提供 nodejs-legacy 二进制包,其中包含/usr/bin/node 作为符号链接到/usr/bin/nodejs.存档中没有包可能依赖或推荐nodejs-legacy 包,专为上游提供
    兼容性.这个包声明也应该声明一个冲突:与节点包的关系.

<...>

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

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

我还没有找到任何关于 NPM 开发人员采用整个项目的信息,但我认为 npm 包将在某些时候得到修复并且 nodejs-legacy 成为真正的遗产.

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:

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

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.

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

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

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


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.

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

  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.

  2. 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.

<...>

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.

It can be installed using sudo apt-get install 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天全站免登陆