在尝试从ubuntu 12.04安装npm时出错

时间:2023-01-31 21:54:19

I've node,js properly installed from source and I'm trying to install npm but I'm receiving errors doesn't matter the method.

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

I followed this link primarily: Installing Node and Npm from source

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

If I try clone the npm repository and after proceed with make install i got this error message:

如果我尝试克隆npm存储库,在继续进行make安装之后,我得到了这个错误消息:

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

If i choose to install from source with sript (wget or curl) I got the errors bellow (with http or https, doesn't matter):

如果我选择使用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.

If I try to use curl I receive this another error message:

如果我尝试使用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

And If I try to install using sudo apt-get install npm I receive this error:

如果我尝试使用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

I don't know what more I can do tho fi this issue that I'm in trouble for entire day yesterday until now.

昨天一整天我都在为这个问题发愁,到现在我也不知道我还能做什么。

thanks if someone could help me with this.

如果有人能帮我,谢谢。

2 个解决方案

#1


1  

I had the same problems which you faced. As for the last dependency problem go /etc/apt/sources.list.d and delete any node related list if you have any. If you come back and install npm you wont get any dependency problem.

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

But I would strongly recommend don't install npm using apt-get. Its comes by default in nodejs when you follow the instructions from nodejs website (via package manager). There is another catch here. You need sudo permission to install nodejs by this method. And you will face problem in future if you use sudo to install nodejs and npm. Read this to understand how to install node properly in dev machine and production machine.

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

Always use nvm to install nodejs and npm in dev machine. By this way you can avoid using sudo while install other tools from npm like yo, grunt, bower.

总是使用nvm在dev机器中安装nodejs和npm。通过这种方式,您可以避免在安装npm的其他工具时使用sudo,比如yo, grunt, bower。

In short,

简而言之,

  1. Install NVM using this link
  2. 使用此链接安装NVM
  3. Install nodejs using NVM. NPM comes by default with nodejs.
  4. 安装使用NVM nodejs。NPM默认使用nodejs。

#2


2  

AFAIK, npm is installed along with the node binary when you install nodejs package.

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

#1


1  

I had the same problems which you faced. As for the last dependency problem go /etc/apt/sources.list.d and delete any node related list if you have any. If you come back and install npm you wont get any dependency problem.

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

But I would strongly recommend don't install npm using apt-get. Its comes by default in nodejs when you follow the instructions from nodejs website (via package manager). There is another catch here. You need sudo permission to install nodejs by this method. And you will face problem in future if you use sudo to install nodejs and npm. Read this to understand how to install node properly in dev machine and production machine.

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

Always use nvm to install nodejs and npm in dev machine. By this way you can avoid using sudo while install other tools from npm like yo, grunt, bower.

总是使用nvm在dev机器中安装nodejs和npm。通过这种方式,您可以避免在安装npm的其他工具时使用sudo,比如yo, grunt, bower。

In short,

简而言之,

  1. Install NVM using this link
  2. 使用此链接安装NVM
  3. Install nodejs using NVM. NPM comes by default with nodejs.
  4. 安装使用NVM nodejs。NPM默认使用nodejs。

#2


2  

AFAIK, npm is installed along with the node binary when you install nodejs package.

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

相关文章