YMFE/yapi · critical

config.json配置了插件${plugin},但plugins目录没有找到此插件,请安装此插件

Error message

config.json配置了插件${plugin},但plugins目录没有找到此插件,请安装此插件

What it means

When loading a regular (non-system) plugin declared in config.json, YApi checks that plugins/yapi-plugin-<name>/server.js exists; if not found it throws this error. config.json references a plugin that is not installed under the plugins directory (plugin_path).

Source

Thrown at server/plugin.js:244

    }
    return Promise.all(promiseAll);
  }
}

yapi.bindHook = bindHook;
yapi.emitHook = emitHook;
yapi.emitHookSync = emitHook;

let pluginsConfig = initPlugins(yapi.WEBCONFIG.plugins, 'plugin');
pluginsConfig.forEach(plugin => {
  if (!plugin || plugin.enable === false || plugin.server === false) return null;

  if (
    !yapi.commons.fileExist(
      yapi.path.join(plugin_path, 'yapi-plugin-' + plugin.name + '/server.js')
    )
  ) {
    throw new Error(`config.json配置了插件${plugin},但plugins目录没有找到此插件,请安装此插件`);
  }
  let pluginModule = require(yapi.path.join(
    plugin_path,
    'yapi-plugin-' + plugin.name + '/server.js'
  ));
  pluginModule.call(yapi, plugin.options);
});

extConfig = initPlugins(extConfig, 'ext');

extConfig.forEach(plugin => {
  if (!plugin || plugin.enable === false || plugin.server === false) return null;

  if (
    !yapi.commons.fileExist(
      yapi.path.join(plugin_system_path, 'yapi-plugin-' + plugin.name + '/server.js')
    )
  ) {

View on GitHub (pinned to 59bade3a8a)

Solutions

  1. Install the plugin: yapi plugin --name=<pluginName> (or npm install the plugin package into plugins/).
  2. Fix the plugin name in config.json to match the installed directory.
  3. Remove the plugin entry from config.json if not needed.
  4. Verify the path plugins/yapi-plugin-<name>/server.js exists on the server.

Example fix

// before (config.json)
"plugins": [{"name": "statistics"}] // not installed
// after (shell)
yapi plugin --name=statistics
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs'), path = require('path');
function pluginInstalled(name, pluginsDir) {
  return fs.existsSync(path.join(pluginsDir, `yapi-plugin-${name}`, 'server.js'));
}
// before startup:
for (const p of config.plugins) {
  if (!pluginInstalled(p.name, './plugins')) {
    throw new Error(`Plugin ${p.name} listed in config.json is not installed`);
  }
}

Try / catch

try {
  startServer();
} catch (e) {
  if (/plugins目录没有找到此插件/.test(e.message)) {
    console.error('Run: yapi plugin --name=<missing plugin>');
    process.exit(1);
  } else { throw e; }
}

Prevention

When it happens

Trigger: config.json plugins array contains {name: 'x'} but yapi-plugin-x is not installed in the plugins directory (file plugins/yapi-plugin-x/server.js missing) at startup.

Common situations: Forgot 'yapi plugin --name=x' install step after adding to config.json; cloned repo without node_modules/plugins; typo in plugin name; deployment excluded plugins dir.

Related errors


AI-assisted analysis of YMFE/yapi@59bade3a8a (2026-08-29). Data as JSON: /api/errors/b48ec6c822fd866e. Report an issue: GitHub.