【问题标题】:Getting error when trying to install npm from source ubuntu 12.04尝试从源 ubuntu 12.04 安装 npm 时出错
【发布时间】:2015-11-27 05:22:42
【问题描述】:

我已经从源代码正确安装了 node,js,我正在尝试安装 npm,但我收到的错误与方法无关。

我主要关注这个链接:Installing Node and Npm from source

如果我尝试克隆 npm 存储库并在继续 make install 后收到此错误消息:

scripts/doc-build.sh: line 58: ./node_modules/.bin/marked: No such file or directory
make: *** [html/doc/api/npm-uninstall.html] Error 1

如果我选择使用 sript(wget 或 curl)从源代码安装,则会出现以下错误(使用 http 或 https,没关系):

wget http://npmjs.org/install.sh                                 
--2014-05-13 00:52:25--  http://npmjs.org/install.sh
Connecting to 127.0.0.1:8118... failed: Connection refused.

如果我尝试使用 curl,我会收到另一条错误消息:

curl https://npmjs.org/install.sh | sh
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                               Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) couldn't connect to host

如果我尝试使用 sudo apt-get install npm 安装,我会收到此错误:

The following packages have unmet dependencies:
 npm : Depends: nodejs but it is not going to be installed
       Depends: nodejs-dev
       Depends: node-request but it is not going to be installed
       Depends: node-mkdirp but it is not going to be installed
       Depends: node-minimatch but it is not going to be installed
       Depends: node-semver but it is not going to be installed
       Depends: node-ini but it is not going to be installed
       Depends: node-graceful-fs but it is not going to be installed
       Depends: node-abbrev but it is not going to be installed
       Depends: node-nopt but it is not going to be installed
       Depends: node-fstream but it is not going to be installed
       Depends: node-rimraf but it is not going to be installed
       Depends: node-tar but it is not going to be installed
       Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
node -v                                                     
v0.11.14-pre

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.4 LTS
Release:    12.04
Codename:   precise


which node
/home/user/local/node/node

我不知道我还能做些什么,因为这个问题我昨天到现在都遇到了一整天的麻烦。

感谢有人能帮我解决这个问题。

【问题讨论】:

  • 你不只是 apt-get install npm 吗?

标签: node.js ubuntu npm


【解决方案1】:

AFAIK,当您安装 nodejs 包时,npm 与 node 二进制文件一起安装。

【讨论】:

  • 我正在使用 ppa:chris-lea/node.js
【解决方案2】:

我遇到了和你一样的问题。至于最后一个依赖问题,请转到/etc/apt/sources.list.d 并删除任何与节点相关的列表(如果有的话)。如果你回来安装 npm,你不会遇到任何依赖问题。

但我强烈建议不要使用 apt-get 安装 npm。 当您按照 nodejs 网站上的说明(通过包管理器)时,它默认出现在 nodejs 中。这里还有另一个问题。您需要 sudo 权限才能通过此方法安装 nodejs。如果您使用 sudo 安装 nodejs 和 npm,您将来会遇到问题。阅读this,了解如何在开发机器和生产机器上正确安装节点。

始终使用nvm 在开发机器中安装 nodejs 和 npm。通过这种方式,您可以在从 npm 安装其他工具(如 yo、grunt、bower)时避免使用 sudo。

总之,

  1. 使用此link 安装 NVM
  2. 使用 NVM 安装 nodejs。 NPM 默认带有 nodejs。

【讨论】:

    猜你喜欢
    • 2015-06-24
    • 1970-01-01
    • 2012-09-02
    • 2013-12-17
    • 1970-01-01
    • 2011-12-04
    • 1970-01-01
    • 2016-03-01
    • 1970-01-01
    相关资源
    最近更新 更多