Unitech/pm2 · error · Error

No app_name defined

Error message

No app_name defined

What it means

getModuleConf is an internal helper in the NPM module loader that reads per-module configuration from PM2's Configuration store, keyed by app_name. It is a hard precondition: it must receive a non-empty module identifier, otherwise it has nothing to look up.

Source

Thrown at lib/API/Modules/NPM.js:328

  Configuration.unsetSync(cst.MODULE_CONF_PREFIX + ':' + module_name_only);

  CLI.deleteModule(module_name_only, function(err, data) {
    console.log('Deleting', proc_path)
    if (module_name != '.' && proc_path.includes('modules') === true) {
      deleteFolderRecursive(proc_path)
    }

    if (err) {
      Common.printError(err);
      return cb(err);
    }

    return cb(null, data);
  });
}

function getModuleConf(app_name) {
  if (!app_name) throw new Error('No app_name defined');

  var module_conf = Configuration.getAllSync();

  var additional_env = {};

  if (!module_conf[app_name]) {
    additional_env = {};
    additional_env[app_name] = {};
  }
  else {
    additional_env = Common.clone(module_conf[app_name]);
    additional_env[app_name] = JSON.stringify(module_conf[app_name]);
  }
  return additional_env;
}

function StartModule(CLI, opts, cb) {
  if (!opts.cmd && !opts.package) throw new Error('module package.json not defined');

View on GitHub (pinned to 31adee8048)

Solutions

  1. Resolve and pass a valid module name string to the module install/start flow.
  2. Verify the module source (git URL, tarball, dir) yields a canonical name before invoking module APIs.
Defensive patterns

Strategy: validation

Validate before calling

const name = require('./Utility').getCanonicModuleName(rawName);
if (!name || typeof name !== 'string') {
  throw new Error('Could not resolve a module name before reading module config');
}

Type guard

const isNonEmptyString = (v) => typeof v === 'string' && v.trim().length > 0;

Prevention

When it happens

Trigger: Internal code path invokes getModuleConf() with undefined/empty/'' because the module name could not be resolved upstream (e.g. a module install where getCanonicModuleName returned empty).

Common situations: Programmatic wrappers around PM2's module install/start API that pass an opts object missing a resolvable name; installing a module whose tarball/dir has no parseable name.

Related errors


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