bug^君 2014-01-16 17:02 采纳率: 25%
浏览 489
已采纳

无法在 Ubuntu 中使用节点包管理器安装软件包

NodeJS interpreter name(node) on Ubuntu has been renamed to nodejs because of 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 upstreams, 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?

转载于:https://stackoverflow.com/questions/21168141/cannot-install-packages-using-node-package-manager-in-ubuntu

  • 写回答

17条回答 默认 最新

  • 七度&光 2014-01-16 19:34
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(16条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器