[Legacy] Node.js Installation Guide

Start by Trying Hud Locally

Ready to run in production? Jump to Hud Installation: Run in Production.


Installation Overview

  1. Install SDK package
  2. Initialize Hud with your service
  3. Upload Sourcemaps (explanation below)
  4. Run your service!



1. Install SDK package

Run the installation command according to your package manager.

npm install hud-sdk
yarn add hud-sdk
pnpm add hud-sdk



2. Initialize Hud with your service

📘

Hud’s auto init uses --require parameter to be loaded before any other module. This ensures that we can instrument any upcoming module’s functions.

Copy the terminal command based on your preferred framework. Fill in the API key provided to you (use 'Local' key), and your unique service name.

Learn more about Hud Configuration.

HUD_ENABLE=true \
HUD_KEY=[YOUR_API_KEY] \
HUD_SERVICE=[YOUR_SERVICE_NAME] \
node --require hud-sdk/init [YOUR_ENTRY_POINT].js
HUD_ENABLE=true \
HUD_KEY=[YOUR_API_KEY] \
HUD_SERVICE=[YOUR_SERVICE_NAME] \
nest start --exec "node --require hud-sdk/init"
HUD_ENABLE=true \
HUD_KEY=[YOUR_API_KEY] \
HUD_SERVICE=[YOUR_SERVICE_NAME] \
NODE_OPTIONS='--require=hud-sdk/init' next start
HUD_ENABLE=true \
HUD_KEY=[YOUR_API_KEY] \
HUD_SERVICE=[YOUR_SERVICE_NAME] \
NODE_OPTIONS='--require=hud-sdk/init' npm run start
//project.json

"my-app": {
  "targets": {
    "serve": {
      "executor": "@nx/js:node",
      "options": {
        "runtimeArgs": ["--require", "hud-sdk/init"],
        //...
      },
    },
  }
}

Are you using ESM? Go to ESM instrumentation.

Note: Hud can also initialize using a code snippet. Learn more.




3. Upload Sourcemaps

📘

What is it? Sourcemaps are files that map your minified or transpiled JavaScript code back to the original source code. When utilizing a transpiler or bundler, the source code is transformed into a different format for distribution, typically consolidated into a limited number of files.

Hud uses sourcemaps to translate the running code into its original form (the source code form).

Select your transpiler or bundler to continue.




4. Run your Service

Now it's the time to run your service. Then, check out your data flowing:

  • Enter Services and spot your new active service.
  • Make sure to select the right environment: Local.
  • Click on the service to see metrics.

No results? Let's troubleshoot.