ecgalaxy.nodejs

ECGALAXY Node.js

===============

This is an Ansible role that installs Node.js globally.

Requirements


  • If you're using Ubuntu, you need gpg-agent, which is included in ecgalaxy.common_packages.

Role Variables


  • nodejs_version: Specify the Node.js version you want to install (like "18.x" or "20.x"). The default version is 20.x.

If you want to install a specific version from a downloadable file, you can set these variables:

  • nodejs_download_url: The link to download the Node.js archive (check https://nodejs.org/dist/)
  • nodejs_checksum: The checksum for the archive
  • nodejs_install_path: The location where Node.js will be installed

About Node.js 18.x, 20.x and 22.x on Amazon Linux 2


You cannot use the official pre-built Node.js 18.x, 20.x, and 22.x binaries on Amazon Linux 2 because of binary compatibility issues.

AWS recommends compiling these Node.js versions from source if you are using Amazon Linux 2 (AL2).

You can find pre-built Node.js 18.x, 20.x, and 22.x binaries for Amazon Linux 2 at: https://code.europa.eu/ecgalaxy/amazonlinux2-nodejs/-/packages

This Ansible role will download them when run on AL2 and save them in the /opt/nodejs/<nodejs_version> folder.

It will also create shortcuts to the Node.js executables in /usr/local/bin.

You may want to update your $PATH variable to include the /opt/nodejs/<nodejs_version>/bin folder.

Using this with nvm works well; you can run nvm use system to access the "global" Node.js version found in /opt/nodejs/<nodejs_version>.

You can also use this role to install Node.js versions 18.x, 20.x, and 22.x globally, and then replace the contents of ~/.nvm/versions/node/v<nodejs_version> for each version, allowing you to switch between versions with nvm use.

Dependencies


  • Optional: ecgalaxy.bootstrap
  • Optional: ecgalaxy.common_packages

Example Playbook


- hosts: all
  roles:
    - ecgalaxy.bootstrap
    - ecgalaxy.common_packages
    - ecgalaxy.nodejs

One-liner


To install the default Node.js version globally, run:

bash <(curl -s https://code.europa.eu/-/snippets/1/raw/main/ansible-role.sh) ecgalaxy.nodejs

To install Node.js 18.x globally, run:

bash <(curl -s https://code.europa.eu/-/snippets/1/raw/main/ansible-role.sh) ecgalaxy.nodejs --extra-vars '{"nodejs_version":"18.x"}'

For instructions, check ansible-role.

Make sure to check the script's integrity first.

License


Copyright © European Union 2022.

This work is licensed under EUPL-1.2 or later.

Author Information


By the ECGALAXY team.

NOTE: This role is based on the original work by Jeff Geerling.

Informazioni sul progetto

Ansible role that installs Node.js

Installa
ansible-galaxy install ecgalaxy.nodejs
Licenza
eupl-1.2
Download
6.5k
Proprietario
The European Commission ECGALAXY project provides a set of reusable Infrastructure as Code (IaC) tools and components