在AWS EC2上安装NPM

在AWS上使用Ec2。

我已经安装Node.js,它工作正常。

但是当试图安装npm时会出现问题。

我正在使用以下命令来安装它:

sudo curl http://npmjs.org/install.sh | sh 

但安装似乎冻结…我得到“提取: http : //registry.npmjs.org/npm/-/npm-1.0.106.tgz ”在提示符下,它保持这样。

有什么想法发生在这里?

 sudo yum install nodejs npm --enablerepo=epel 

要安装NodeJS 6.x,请执行以下命令:

 curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash - yum install nodejs --enablerepo=nodesource 

更新

您可以用相同的方法安装NodeJS 7和8。 只需在上面的命令中指定您需要的版本而不是6。

遵循使用节点版本pipe理器的 AWS教程 。

节点版本pipe理器(NVM)允许您安装多个版本的Node.js并在它们之间切换。


这里是步骤:

安装NVM

 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash 

激活NVM

 . ~/.nvm/nvm.sh 

安装节点(select版本)

 nvm install 4.4.5 

确认成功安装

 node -e "console.log('Running Node.js ' + process.version)" 

我发现他的教程对我来说非常有用:最后一章解释了如何安装node和npm编译它。

http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/#installNode

git clone https://github.com/isaacs/npm.git cd npm sudo make install

如果你没有git,首先要做的是: sudo yum install git

编辑为我的答案是不相关的了:

尝试:

 curl --silent --location https://rpm.nodesource.com/setup | bash - yum -y install nodejs 

https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#enterprise-linux-and-fedora-core