node.js 在 AWS EC2 上安装 NPM
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8205369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing NPM on AWS EC2
提问by dade
Working on Ec2 on AWS.
在 AWS 上使用 Ec2。
I have installed Node.js and it works fine.
我已经安装了 Node.js,它运行良好。
But the problem arises when trying to install npm.
但是在尝试安装 npm 时出现了问题。
I am using the following command to install it:
我正在使用以下命令来安装它:
sudo curl http://npmjs.org/install.sh | sh
But the install seems to freeze... I get "fetching: http://registry.npmjs.org/npm/-/npm-1.0.106.tgz" at the prompt and it stays on like this.
但是安装似乎冻结了......我在提示符下收到“fetching: http://registry.npmjs.org/npm/-/npm-1.0.106.tgz”并且它一直这样。
Have any idea what is going on here?
知道这里发生了什么吗?
采纳答案by Derek Soike
Follow this AWS Tutorialthat uses Node Version Manager.
遵循使用Node Version Manager 的AWS 教程。
Node Version Manager (NVM) lets you install multiple versions of Node.js and switch between them.
Node Version Manager (NVM) 允许您安装 Node.js 的多个版本并在它们之间切换。
Here are the steps:
以下是步骤:
Install NVM
安装 NVM
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
Activate NVM
激活 NVM
. ~/.nvm/nvm.sh
Install Node (choose version)
安装节点(选择版本)
nvm install 4.4.5
Confirm Successful Installation
确认安装成功
node -e "console.log('Running Node.js ' + process.version)"
回答by Ted
sudo yum install nodejs npm --enablerepo=epel
回答by Ihor Burlachenko
To install NodeJS 6.x execute the following commands:
要安装 NodeJS 6.x,请执行以下命令:
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -
yum install nodejs --enablerepo=nodesource
Update
更新
You can install NodeJS 7 and 8 in the same way. Just specify the version you need instead of 6 in the command above.
你可以用同样的方式安装 NodeJS 7 和 8。只需在上面的命令中指定您需要的版本而不是 6。
Update
更新
To update to NodeJS 10 (or any other version) do the following:
要更新到 NodeJS 10(或任何其他版本),请执行以下操作:
rm -rf /etc/yum.repos.d/nodesource-el*
curl -sL https://rpm.nodesource.com/setup_10.x | sudo -E bash -
yum install nodejs --enablerepo=nodesource
回答by Khurram
Firstly
首先
sudo yum install make
须藤 yum 安装 make
You can run this to get zip of desired version of node
您可以运行它以获取所需节点版本的 zip
wget https://nodejs.org/dist/v8.10.0/node-v8.10.0.tar.gz
Then you can unzip it like this
然后你可以像这样解压它
tar -xvf node-v8.10.0.tar.gz
then go in to the extracted directory and install node like this
然后进入解压目录并像这样安装节点
./configure && make && sudo make install
回答by wilco
git clone https://github.com/isaacs/npm.git
cd npm
sudo make install
git clone https://github.com/isaacs/npm.git
cd npm
sudo make install
And if you don't have git, do this first:
sudo yum install git
如果您没有 git,请先执行以下操作:
sudo yum install git
回答by jbaylina
I found his tutorial that has been very usefull to me: The last chapter explains how to install node and npm compiling it.
我发现他的教程对我非常有用:最后一章解释了如何安装 node 和 npm 编译它。
http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/#installNode
http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/#installNode
回答by William Woodruff
Get the http://npmjs.org/install.shfile on your system first and then execute it directly instead of piping with curl.
http://npmjs.org/install.sh首先在您的系统上获取文件,然后直接执行它而不是使用 curl 管道。
- Use
chmod +x install.shto make it executable - Then run
./install.sh
- 使用
chmod +x install.sh使其可执行 - 然后运行
./install.sh
回答by fkoessler
Edit as my answer wasn't pertinent anymore:
编辑,因为我的答案不再相关:
Try:
尝试:
curl --silent --location https://rpm.nodesource.com/setup | bash -
yum -y install nodejs

