Unitech/pm2 · error · Error

Unknown platform / init system name

Error message

Unknown platform / init system name

What it means

After platform is resolved, PM2 switches over the recognized init systems (systemd, upstart, launchd, systemv, openrc, rcd, rcd-openbsd, smf) to pick the matching template and commands. Reaching the default case means a platform string was supplied that is not in that set.

Source

Thrown at lib/API/Startup.js:331

      destination = '/etc/init.d/' + service_name;
      commands = [
        'chmod +x ' + destination,
        'rc-update add ' + service_name + ' default'
      ];
      break;
    case 'smf':
    case 'sunos':
    case 'solaris':
      template = getTemplate('smf');
      service_name = (opts.serviceName || 'pm2_' + user);
      destination = path.join(tmpPath(), service_name + '.xml');
      commands = [
        'svccfg import ' + destination,
        'svcadm enable ' + service_name
      ];
      break;
    default:
      throw new Error('Unknown platform / init system name');
    }

    /**
     * 4# Replace template variable value
     */
    var envPath

    if (cst.HAS_NODE_EMBEDDED == true)
      envPath = util.format('%s:%s', process.env.PATH || '', path.dirname(process.execPath))
    else if (new RegExp(path.dirname(process.execPath)).test(process.env.PATH))
      envPath = process.env.PATH
    else
      envPath = util.format('%s:%s', process.env.PATH || '', path.dirname(process.execPath))

    let pm2_bin_path = require.main.filename

    if (pm2_bin_path.includes('/lib/binaries/CLI.js') === true) {
      pm2_bin_path = pm2_bin_path.replace('/lib/binaries/CLI.js', '/bin/pm2')

View on GitHub (pinned to 31adee8048)

Solutions

  1. Use one of the supported names: systemd, upstart, launchd, systemv, openrc, rcd, rcd-openbsd, smf.
  2. Run `pm2 startup` with no argument and let PM2 auto-detect.
  3. Double-check spelling against the supported list.

Example fix

// before
pm2 startup systemctl
// after
pm2 startup systemd
Defensive patterns

Strategy: validation

Validate before calling

const VALID = ['systemd','upstart','launchd','systemv','openrc','rcd','rcd-openbsd','smf'];
if (!VALID.includes(platform)) {
  throw new Error(`Unsupported platform '${platform}'; use one of: ${VALID.join(', ')}`);
}

Type guard

const isKnownPlatform = (p) =>
  ['systemd','upstart','launchd','systemv','openrc','rcd','rcd-openbsd','smf'].includes(p);

Prevention

When it happens

Trigger: Passing an invalid or misspelled platform to `pm2 startup <platform>` — e.g. `pm2 startup systemctl` (the tool name rather than the init name) or `pm2 startup systemds`.

Common situations: Confusing the init-system name (systemd) with its tool (systemctl); typos; passing a made-up platform string.

Related errors


AI-assisted analysis of Unitech/pm2@31adee8048 (2026-08-13). Data as JSON: /api/errors/1a908a1c96245633. Report an issue: GitHub.