Skip to content

Installing NodeJS on Amazon Linux

Created: 2016-02-17 12:46:19 -0800 Modified: 2016-11-07 16:15:03 -0800

Note: I adapted the instructions below from this page. It turns out that all of the scripts you may need are sourced from this GitHub.

  • First, figure out which major version of Node you want.
  • The scripts are saved in GitHub, but they’re also hosted based on whether you’re using “rpm” as your package manager or if you’re using “apt-get” on Debian or Ubuntu (“deb”).
  • curl the script
    • curl https://rpm.nodesource.com/setup_5.x -o ./setup_node_5x.sh
      • You could also curl it directly into bash: curl <URL> | sudo bash -
    • chmod +x ./setup_node_5x.sh
    • If you already had an installation of NodeJS or NPM on your machine, you should remove it first.
      • sudo yum remove -y nodejs npm
    • sudo ./setup_node_5x.sh
    • When you’re ready to install:
      • Specific version (e.g. 5.5.0 instead of 5.6.0)
        • yum —showduplicates list nodejs
        • Pick which version you want by appending the middle column to “nodejs-”
          • sudo yum install nodejs-5.5.0-1nodesource.el7.centos
      • Latest version
        • sudo yum install -y nodejs
    • Finally, you also need gcc-c++ and make for compiling native modules:
      • sudo yum install -y gcc-c++ make
  • You may want to get node-gyp for building modules:
    • sudo npm -g install node-gyp