Socket
Book a DemoInstallSign in
Socket

pm2-ecosystem

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pm2-ecosystem

Type PM2 configuration files. Use JSDoc or the define-app function.

6.0.10
latest
Source
npmnpm
Version published
Weekly downloads
67
3250%
Maintainers
1
Weekly downloads
 
Created
Source

pm2-ecosystem

Type-safe PM2 configurations without the pm2 package - quick start

Justification

PM2 does provide TypeScript types out-of-the box.

module.exports = {
  /** @type {import('pm2').StartOptions[]} */
  apps: [{ name: 'app', script: './app.js' }],
};

However, pm2 is not meant to be installed locally.

# Reference https://pm2.keymetrics.io/docs/usage/quick-start/
npm install pm2@latest -g
yarn global add pm2

Since there is no @types/pm2 package, use this instead.

Quick Start

npm i pm2-ecosystem -D
pnpm i pm2-ecosystem -D
// Method 1: Using the `defineApp` function

const { defineApp } = require('pm2-ecosystem');

module.exports = {
  apps: [
    defineApp({ name: 'app1', script: './app1.js' }),
    defineApp({ name: 'app2', script: './app2.js' }),
    // ...
  ],
};

// Method 2: Using JSDoc

module.exports = {
  /** @type {import('pm2-ecosystem').StartOptions[]} */
  apps: [
    { name: 'app1', script: './app1.js' },
    { name: 'app2', script: './app2.js' },
  ],
};

ECMAScript Modules

In a ESM project, the JavaScript configuration file must have the .cjs extension.

Example Filenamepackage.json
ecosystem.config.js"type": "commonjs"
ecosystem.config.cjs"type": "module"
# If the filename is `ecosystem.config.js`
pm2 start # the filename can be omitted.
pm2 start ecosystem.config.js

# If not, the filename must be specified.
pm2 start ecosystem.config.cjs
pm2 start pm2.config.cjs

FAQs

Package last updated on 03 Sep 2025

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.