Skip to content

Node.js

Node.js runtime and npm package manager run JavaScript applications and manage dependencies


The HPC system provides Node.js v10.24.0 and npm v6.14.11 for running JavaScript and managing packages.
This system version is intentionally older for compatibility reasons, but users may install newer versions of Node.js in their home directory using NVM (Node Version Manager).

Example Usage#

Create a file named hello.js with the following content:

console.log("Hello from Node.js on the HPC!");

Run it with:

$ node hello.js

Additionally you can install packages locally using npm:

1
2
3
4
$ mkdir my_project
$ cd my_project
$ npm init -y                # Initialize a project
$ npm install lodash         # Example: install lodash library

After installation, you can use the packages in your Node.js scripts.

For more information visit the Node.js or npm documentation websites.

Installing a Newer Node.js Version Using NVM#

Users who need modern Node.js features can install a newer version without administrator privileges using nvm.

This method installs Node.js entirely in your home directory.

1. Install NVM#

Run the official installation script:

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

Then reload your environment so that nvm becomes available:

$ source ~/.bashrc

You can verify installation with:

$ command -v nvm

If the command prints nvm, the installation succeeded.

2. Install a New Node.js Version#

Use nvm to install the current LTS release:

$ nvm install --lts

Or install a specific version:

$ nvm install 20

Confirm the version:

$ node -v

3. Set a Default Node.js Version#

To automatically use a specific version each time you log in:

$ nvm alias default 20

4. Installing Packages With NVM-Managed Node#

Once you've activated the desired Node.js version, you can use npm normally:

1
2
3
4
$ mkdir my_app
$ cd my_app
$ npm init -y
$ npm install express

All packages are stored in your home directory, isolated from the system installation.