Connect to your Linux instance as
ec2-user
using SSH.Install the current version of node version manager (nvm) by typing the following at the command line to install version 33.8.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
We will use nvm to install Node.js because nvm can install multiple versions of Node.js and allow you to switch between them. See the nvm repo on GitHub for the current version to install.
Activate nvm by typing the following at the command line.
. ~/.nvm/nvm.sh
Use nvm to install the version of Node.js you intend to use by typing the following at the command line.
nvm install 6.11.5
To install the latest LTS (long-term-support) release of Node.js, type the following at the command line.
nvm install --lts
Installing Node.js also installs the Node Package Manager (npm) so you can install additional modules as needed.
Test that Node.js is installed and running correctly by typing the following at the command line.
node -e "console.log('Running Node.js ' + process.version)"
This should display the following message that confirms the installed version of Node.js running.
Running Node.js v6.11.5
这种方法不用手动配置文件,还是很方便,百度找的几个配置方法都没成功,最后找到这个,终于可以了。。
1.通过SSH连接Linux(我用的xshell)
2.安装nvm / node version manager
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
3.激活nvm
. ~/.nvm/nvm.sh
4.安装nodejs 和 LTS (long-term-support)
nvm install 6.11.5
nvm install --lts
5.测试安装是否成功。成功的话会输出 Running Node.js v6.11.5
node -e "console.log('Running Node.js ' + process.version)"
原文链接
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html