繁体   English   中英

尝试从源ubuntu 12.04安装npm时出现错误

[英]Getting error when trying to install npm from source ubuntu 12.04

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

我主要遵循此链接: 从源代码安装Node和Npm

如果我尝试克隆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

我不知道该怎么办,因为昨天到现在为止我整天都遇到麻烦。

谢谢有人帮助我。

AFAIK,在安装nodejs软件包时,npm与节点二进制文件一起安装。

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

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

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

简而言之,

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM