{"record":{"id":"b48ec6c822fd866e","repo":"YMFE/yapi","slug":"config-json-plugin-plugins","errorCode":null,"errorMessage":"config.json配置了插件${plugin},但plugins目录没有找到此插件，请安装此插件","messagePattern":"config\\.json配置了插件(.+?),但plugins目录没有找到此插件，请安装此插件","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/plugin.js","lineNumber":244,"sourceCode":"    }\n    return Promise.all(promiseAll);\n  }\n}\n\nyapi.bindHook = bindHook;\nyapi.emitHook = emitHook;\nyapi.emitHookSync = emitHook;\n\nlet pluginsConfig = initPlugins(yapi.WEBCONFIG.plugins, 'plugin');\npluginsConfig.forEach(plugin => {\n  if (!plugin || plugin.enable === false || plugin.server === false) return null;\n\n  if (\n    !yapi.commons.fileExist(\n      yapi.path.join(plugin_path, 'yapi-plugin-' + plugin.name + '/server.js')\n    )\n  ) {\n    throw new Error(`config.json配置了插件${plugin},但plugins目录没有找到此插件，请安装此插件`);\n  }\n  let pluginModule = require(yapi.path.join(\n    plugin_path,\n    'yapi-plugin-' + plugin.name + '/server.js'\n  ));\n  pluginModule.call(yapi, plugin.options);\n});\n\nextConfig = initPlugins(extConfig, 'ext');\n\nextConfig.forEach(plugin => {\n  if (!plugin || plugin.enable === false || plugin.server === false) return null;\n\n  if (\n    !yapi.commons.fileExist(\n      yapi.path.join(plugin_system_path, 'yapi-plugin-' + plugin.name + '/server.js')\n    )\n  ) {","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/YMFE/yapi/blob/59bade3a8a43e7db077d38a4b0c7c584f30ddf8c/server/plugin.js#L226-L262","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Install the plugin: yapi plugin --name=<pluginName> (or npm install the plugin package into plugins/).","Fix the plugin name in config.json to match the installed directory.","Remove the plugin entry from config.json if not needed.","Verify the path plugins/yapi-plugin-<name>/server.js exists on the server."],"exampleFix":"// before (config.json)\n\"plugins\": [{\"name\": \"statistics\"}] // not installed\n// after (shell)\nyapi plugin --name=statistics","handlingStrategy":"validation","validationCode":"const fs = require('fs'), path = require('path');\nfunction pluginInstalled(name, pluginsDir) {\n  return fs.existsSync(path.join(pluginsDir, `yapi-plugin-${name}`, 'server.js'));\n}\n// before startup:\nfor (const p of config.plugins) {\n  if (!pluginInstalled(p.name, './plugins')) {\n    throw new Error(`Plugin ${p.name} listed in config.json is not installed`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  startServer();\n} catch (e) {\n  if (/plugins目录没有找到此插件/.test(e.message)) {\n    console.error('Run: yapi plugin --name=<missing plugin>');\n    process.exit(1);\n  } else { throw e; }\n}","preventionTips":["Install plugins (yapi plugin --name=x) before adding them to config.json.","Keep the plugins directory in deployments and Docker images.","Match plugin name spelling in config.json to the installed package name.","Add a pre-start check that every configured plugin has server.js on disk."],"tags":["plugin","configuration","missing-module"],"backgroundTag":"plugin-not-installed","analyzedSha":"59bade3a8a43e7db077d38a4b0c7c584f30ddf8c","analyzedAt":"2026-08-29T08:45:22.203Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}