{"record":{"id":"72a05fb322db3aaa","repo":"liabru/matter-js","slug":"plugin-use-is-for-but-installed-on","errorCode":null,"errorMessage":"Plugin.use: is for but installed on .","messagePattern":"Plugin\\.use: is for but installed on \\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/core/Plugin.js","lineNumber":153,"sourceCode":"\n        for (var i = 0; i < sortedDependencies.length; i += 1) {\n            if (sortedDependencies[i] === module.name) {\n                continue;\n            }\n\n            var plugin = Plugin.resolve(sortedDependencies[i]);\n\n            if (!plugin) {\n                status.push('❌ ' + sortedDependencies[i]);\n                continue;\n            }\n\n            if (Plugin.isUsed(module, plugin.name)) {\n                continue;\n            }\n\n            if (!Plugin.isFor(plugin, module)) {\n                Common.warn('Plugin.use:', Plugin.toString(plugin), 'is for', plugin.for, 'but installed on', Plugin.toString(module) + '.');\n                plugin._warned = true;\n            }\n\n            if (plugin.install) {\n                plugin.install(module);\n            } else {\n                Common.warn('Plugin.use:', Plugin.toString(plugin), 'does not specify an install function.');\n                plugin._warned = true;\n            }\n\n            if (plugin._warned) {\n                status.push('🔶 ' + Plugin.toString(plugin));\n                delete plugin._warned;\n            } else {\n                status.push('✅ ' + Plugin.toString(plugin));\n            }\n\n            module.used.push(plugin.name);","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/liabru/matter-js/blob/acb99b6f8784c809b940f1d2cf745427e088e088/src/core/Plugin.js#L135-L171","documentation":"Plugin dependencies carry an optional 'for' field naming the module they are intended for (e.g. 'matter-js'). Plugin.use checks Plugin.isFor(plugin, module) before installing; if the plugin declares a 'for' target that doesn't match the module being installed on, the plugin is skipped-not-installed? (actually still installed if plugin.install exists) but warned about, and plugin._warned is set. It signals a mismatch between where the plugin author intended it to run and where you are installing it.","triggerScenarios":"Plugin.use(engineOrModule, [plugin]) where plugin.for is set to a different module name or incompatible version range, e.g. plugin.for = 'matter-wrap' installed on Matter, or plugin.for specifying a version range the module doesn't satisfy.","commonSituations":"Copy-pasting plugin setup code from examples targeting a different base module; plugin written for another library (e.g. p2.js) whose 'for' field was never updated; version range in 'for' outdated after a Matter upgrade.","solutions":["Correct plugin.for to match the module you install on (e.g. 'matter-js' with a suitable version range like '>=0.14.0').","Install the plugin on the module it declares: Plugin.use(window.Matter, [plugin]) instead of a custom module.","Remove/blank the plugin.for field if the plugin is actually generic.","Verify module name/version via Plugin.toString(module) shown in the warning."],"exampleFix":"// before\nconst plugin = { name: 'p', version: '1.0.0', for: 'other-lib', install() {} };\nPlugin.use(Matter, [plugin]); // for-target mismatch\n// after\nconst plugin = { name: 'p', version: '1.0.0', for: 'matter-js@>=0.19.0', install() {} };\nPlugin.use(Matter, [plugin]);","handlingStrategy":"validation","validationCode":"function isForTarget(plugin, moduleName) {\n  if (!plugin.for) return true;\n  const target = plugin.for.split('@')[0];\n  return target === moduleName;\n}\nif (isForTarget(plugin, 'matter-js')) Matter.Plugin.use(Matter, [plugin]);","typeGuard":"function matchesFor(plugin, module) {\n  return !plugin.for || plugin.for === module.name ||\n    String(plugin.for).split('@')[0] === (module.name || 'matter-js');\n}","tryCatchPattern":null,"preventionTips":["Ensure plugin.for names the module you install on (usually 'matter-js')","Include a compatible semver range in 'for' when the plugin depends on Matter version","Update 'for' when adapting plugins from examples or other libraries","Inspect Plugin.toString output in the warning to see actual module vs declared target"],"tags":["plugin","versioning","misconfiguration"],"backgroundTag":"plugin-target-mismatch","analyzedSha":"acb99b6f8784c809b940f1d2cf745427e088e088","analyzedAt":"2026-09-02T21:29:27.057Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}