npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pm2-recover

v1.0.5

Published

A utility to recreate pm2 start commands from a PM2 dump file

Readme

PM2 Dev Mode Recovery Utility

npm version License: MIT

pm2-recover reconstructs your pm2 start commands after nvm switches or OS reinstalls by stripping absolute paths.

Unlike pm2 resurrect or pm2 update, pm2-recover deliberately strips pm2's saved absolute binary paths and environment details, maintaining only the directory from which the process was started from and the pm2 start args.

Usage:

# Save to file for review / editing (recommended)
npx pm2-recover -o recover.sh
bash recover.sh

# One-liner (if you're feeling lucky)
npx pm2-recover | bash

Options:

  • -f, --dumpFile <path>: (Optional) Specify a custom PM2 dump file path. Defaults to ~/.pm2/dump.pm2.
  • -o, --outFile <path>: (Optional) Write generated commands to a file instead of stdout.
  • -h, --help: (Optional) Prints a help message.

Features:

  • Preserves pm2 --watch mode
  • Preserves original working directories
  • Preserves stopped status (pm2 startpm2 stop immediately)
  • Fixes nvm absolute paths
  • Leaves your exact command untouched when using bash -c '...'
  • Works with pm2 managed other-languages (e.g. go run ., bun start:prod --watch, npm run dev)

Important:

  • Run pm2 save before switching Node versions or running this tool to preserve your active process list.
  • pm2-recover does not modify your dump, PM2 system files, or existing processes. It only reads your dump and generates shell commands.
  • pm2-recover does not reconstruct environment variables (your process.env).
  • This tool doesn't install pm2 / nvm / node for you.

Example:

  • npx pm2-recover -f /path/to/custom-pm2-dump.json: custom dump.pm2 path.
  • npx pm2-recover -o recovery-script.sh: writes the output to a file.
  • npx pm2-recover | bash: directly try to execute the output by piping to bash.

Here's an anonymized actual output from npx pm2-recover straight from my own dev machine:

#!/bin/bash
# --- PM2 Relaunch Commands Generated by pm2-recover ---
# Input File: /home/developer/.pm2/dump.pm2
# Structure: pm2 start --name NAME COMMAND [OPTIONS] -- ARGS

# Sets bash to stop script execution immediately after error
set -euo pipefail

# Execute pm2 kill first to ensure all pm2 processes are freshly recreated.
# Skip this line if you don't need to.
pm2 kill || true

# [Shell-Wrapped] Process: web-client
cd "/path/to/project/web-client" && pm2 start --name web-client  'npm run dev'

# [Shell-Wrapped] Process: api-gateway
cd "/path/to/project/api-gateway" && pm2 start --name api-gateway  'gow run .'

# [Shell-Wrapped] Process: data-processor
cd "/path/to/project/data-processor" && pm2 start --name data-processor  'bun consume:events'
pm2 stop data-processor

# [Shell-Wrapped] Process: analytics-backend
cd "/path/to/project/analytics-backend" && pm2 start --name analytics-backend  'npm run start:dev'

# [Shell-Wrapped] Process: content-editor
cd "/path/to/project/content-editor" && pm2 start --name content-editor 'npx parcel public/*.html --port 1234'
pm2 stop content-editor

# [Direct Exec] Process: auth-service
cd "/path/to/project/authService/entrypoints" && pm2 start --name auth-service  './auth-middleware' -- '--config' 'original.yaml'

# --- FINALIZATION ---
pm2 save
pm2 list

When to use

pm2-recover might help you if:

  • pm2 resurrect fails after switching Node versions via nvm
  • PM2 shows your app as errored due to missing binary paths
  • Your PM2 dump contains values like /home/user/.nvm/versions/node/vXX/bin
  • You reinstalled your OS or moved your workspace
  • You want portable, clean pm2 start commands
  • You have a lot of pm2 processes you need to evaluate how it starts

Why pm2 resurrect Fails After nvm Node Version Switches

For a dev machine, pm2 is great to keep a lot of services running and to start/stop services as we switch projects without having to remember the start script.

However, when we run pm2 without an ecosystem.config.js, we might run a service like this:

cd /home/developer/projects/myDevApp/
pm2 start --name myDevApp 'npm run dev'

Which can result in something like this within dump.pm2:

{
  "args": [
    "-c",
    "npm run dev"
  ],
  "name": "myDevApp",
  "pm_cwd": "/home/developer/projects/myDevApp",
  "pm_exec_path": "/usr/bin/bash",
  "status": "online",
  "watch": false,
  //                         👇 NVM_DIR        👇 versioned NodeJS
  "PATH": "/home/developer/.nvm/versions/node/v24.11.1/bin:/usr/local/bin:/usr/bin:/usr/local/sbin"
  //                  versioned npm/node binary is here 👆🏻
}

Which is great for servers where we might have consistent paths. The moment we:

  • changed node version and have nvm to remove the older version
  • change NVM_DIR

Or other things that makes the old execution environment no longer available, pm2 resurrect breaks.

The easiest way to really "restore" the wounded service is cd to the directory and re-run pm2 start -- exactly what pm2-recover tries to help you with.