npm.io
1.0.1 • Published 3 weeks agoCLI

analytics-node-agent

Licence
Version
1.0.1
Deps
2
Size
13 kB
Vulns
0
Weekly
0

analytics-node-agent

A lightweight Node.js monitoring agent that runs as an independent Express-based service and exposes system/runtime analytics.

Install

Install globally to run it as a standalone command:

npm install -g analytics-node-agent

Install locally inside another project:

npm install analytics-node-agent

Run

After global installation, start the service directly from the terminal:

analytics-node-agent

If your package uses a configurable port through environment variables, export them before starting the service:

PORT=4000 analytics-node-agent

PM2

Run it under PM2 as a long-running background process:

pm2 start analytics-node-agent --name analytics-node-agent
pm2 save

If you prefer to run the npm start script from a project checkout, PM2 also supports starting npm directly:

pm2 start npm --name analytics-node-agent -- start

What it does

  • Starts a Node.js service that can run independently after global installation through an executable configured with the bin field in package.json.[1][2]
  • Can be installed globally so the command is linked into npm's global bin directory and run like any other CLI tool.[1][2]
  • Can be managed with PM2 like other Node.js processes, including running via a direct executable or through npm start.[3][4]

Package setup

To work as a terminal command, the package should include:

{
  "name": "analytics-node-agent",
  "version": "1.0.1",
  "type": "module",
  "main": "index.js",
  "bin": {
    "analytics-node-agent": "./index.js"
  },
  "scripts": {
    "start": "node index.js",
    "dev": "nodemon index.js"
  }
}

Your entry file should begin with a shebang so the command can execute correctly when installed globally:[2]

#!/usr/bin/env node

Publish updates

README changes only appear on the npm package page after publishing a new version, so bump the version and publish again after adding this file.[5]

npm version patch
npm publish

Notes

  • Keep README.md in the package root so npm shows it on the package page.[5]
  • Avoid shipping unnecessary files; npm publishes files from your package root into the tarball shown during publish.[5]
  • For a production deployment, use PM2 logs and restart policies after confirming the service starts cleanly.[4]