Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Select Git revision
  • f6442d870e77e0963e45d9b17d1f53f9af08cfe7
  • master default protected
  • 3.0.6
  • 3.0.5
  • 3.0.4
  • 3.0.3
  • 3.0.2
  • 3.0.1
  • 3.0.0
  • 2.6.3
  • 2.6.2
  • 2.6.1
  • 2.6.0
  • 2.5.4
  • 2.5.3
  • 2.5.2
  • 2.5.1
  • 2.5.0
  • 2.4.14
  • 2.4.13
  • 2.4.12
  • 2.4.11
22 results

nodejs

  • Clone with SSH
  • Clone with HTTPS
  • ECGALAXY nodejs

    Ansible role that installs Node.js globally.

    Requirements

    • On Ubuntu, the gpg-agent command, which can be provided by ecgalaxy.common_packages.

    Role Variables

    • nodejs_version: Sets the Node.js version to install ("18.x", "20.x", etc), using the distribution package manager.

    The default version is 20.x.

    Optionally, in order to install a specific version from a downloadable archive, set the below variables:

    • nodejs_download_url: The Node.js archive to download (see https://nodejs.org/dist/)
    • nodejs_checksum: The archive checksum
    • nodejs_install_path: The path where Node.js will be installed

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

    Official Node.js 18.x and 20.x pre-built binaries cannot be used on Amazon Linux 2, due to binary incompatibilities (missing glibc symbol versions).

    AWS recommends to build those Node.js versions from source, when using Amazon Linux 2 (AL2).

    Pre-built Node.js 18x and 20.x binaries for Amazon Linux 2 can be found at https://code.europa.eu/ecgalaxy/amazonlinux2-nodejs/-/packages

    They are downloaded by this Ansible role (when executed on AL2), and saved into the /opt/nodejs/<nodejs_version> folder.

    Symlinks to the Node.js executables are then created in /usr/local/bin.

    You may want to update your $PATH as well, pointing to the /opt/nodejs/<nodejs_version>/bin folder.

    Usage with nvm has been tested successfully; the command nvm use system will correctly point to the "global" Node.js version (saved into /opt/nodejs/<nodejs_version>).

    You can also execute this role to globally install 18.x and 20.x, then overwrite the contents of ~/.nvm/versions/node/v<nodejs_version> for both, which will allow switching from one version to another 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 globally install the default Node.js version:

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

    To globally install Node.js 18.x:

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

    See ansible-role for instructions.

    Please verify the script integrity first.

    License

    Copyright the European Union 2022.

    Licensed under the EUPL-1.2 or later.

    Author Information

    ECGALAXY team.

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