Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

slnodejs

Package Overview
Dependencies
Maintainers
1
Versions
443
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slnodejs

Sealights Node.js Agent

latest
npmnpm
Version
6.1.1153
Version published
Weekly downloads
49K
1.57%
Maintainers
1
Weekly downloads
 
Created
Source

Sealights Node.js Agent

#Preload Script

Overview

The preload.js script serves as an automatic loader for the Sealights Node agent, eliminating the need to explicitly wrap your commands with slnodejs run. This script intercepts the normal Node.js execution flow and injects the necessary Sealights installation logic.

Installation

First, install the Sealights Node.js package:

npm install slnodejs

The preload script will be available at:

./node_modules/slnodejs/lib/preload.js

Usage

Method 1: Using -r flag

node -r ./node_modules/slnodejs/lib/preload.js your-script.js

Method 2: Using NODE_OPTIONS

export NODE_OPTIONS="-r ./node_modules/slnodejs/lib/preload.js"
node your-script.js

Or inline:

NODE_OPTIONS="-r ./node_modules/slnodejs/lib/preload.js" node your-script.js

Using NODE_OPTIONS allows you to persist the preloader configuration across multiple Node.js executions without explicitly specifying the -r flag each time.

Environment Variables Configuration

VariableDescriptionDefault
SL_TOKENDirect Sealights agent authentication token
SL_TOKEN_FILEPath to file containing the Sealights token./sltoken.txt
SL_BUILD_SESSION_IDDirect build session ID
SL_BUILD_SESSION_ID_FILEPath to file containing build session ID./buildSessionId
SL_PROJECT_ROOTRoot directory of your projectCurrent working directory
SL_COLLECTOR_URLURL to Sealights collector
SL_LAB_IDLab ID for test execution

Error Handling

The script includes robust error handling mechanisms:

  • Primary Execution: Attempts to run the target script with Sealights agent configuration
  • Fallback Mechanism: If the primary execution fails, it falls back to running the original command
  • Uncaught Exception Handler: Captures and logs any uncaught exceptions

Examples

Using -r Flag

node -r ./node_modules/slnodejs/lib/preload.js server.js

Using NODE_OPTIONS

# Set for current session
export NODE_OPTIONS="-r ./node_modules/slnodejs/lib/preload.js"
node server.js

# Or inline
NODE_OPTIONS="-r ./node_modules/slnodejs/lib/preload.js" node server.js

Using Environment Variables with NODE_OPTIONS

export NODE_OPTIONS="-r ./node_modules/slnodejs/lib/preload.js"
SL_TOKEN="your-token-here" node server.js

Specifying Custom Paths with NODE_OPTIONS

export NODE_OPTIONS="-r ./node_modules/slnodejs/lib/preload.js"
SL_TOKEN_FILE="/custom/path/token.txt" SL_projectRoot="/path/to/project" node server.js

Using Collector URL and Lab ID with NODE_OPTIONS

export NODE_OPTIONS="-r ./node_modules/slnodejs/lib/preload.js"
SL_TOKEN="your-token-here" SL_COLLECTOR_URL="https://your-collector-url.com" SL_LAB_ID="your-lab-id" node server.js

Debug Mode with NODE_OPTIONS

export NODE_OPTIONS="-r ./node_modules/slnodejs/lib/preload.js"
NODE_DEBUG=sl node server.js

Troubleshooting

If you encounter issues:

  • Check if the token and build session ID files exist and are readable
  • Verify environment variables are set correctly
  • Check console output for error messages (turn on NODE_DEBUG=sl)
  • Ensure the script has necessary permissions to execute

Limitations

  • When using -r flag: Must be explicitly included in each Node.js command
  • When using NODE_OPTIONS: Affects all Node.js processes in the current environment

Best Practices

Choosing Between -r and NODE_OPTIONS

Use -r flag when:

  • You want to explicitly control which scripts use the preloader
  • You're running in an environment where global Node.js settings should not be modified
  • You're running multiple Node.js applications with different configurations

Use NODE_OPTIONS when:

  • You want to ensure all Node.js executions in your session include the preloader
  • You're working in a dedicated development environment
  • You want to reduce command verbosity
  • You're setting up CI/CD pipelines where all Node.js executions should include the preloader and Sealights Agent

FAQs

Package last updated on 05 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts