liabru/matter-js · warning
Plugin.use: is for but installed on .
Error message
Plugin.use: is for but installed on .
What it means
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.
Source
Thrown at src/core/Plugin.js:153
for (var i = 0; i < sortedDependencies.length; i += 1) {
if (sortedDependencies[i] === module.name) {
continue;
}
var plugin = Plugin.resolve(sortedDependencies[i]);
if (!plugin) {
status.push('❌ ' + sortedDependencies[i]);
continue;
}
if (Plugin.isUsed(module, plugin.name)) {
continue;
}
if (!Plugin.isFor(plugin, module)) {
Common.warn('Plugin.use:', Plugin.toString(plugin), 'is for', plugin.for, 'but installed on', Plugin.toString(module) + '.');
plugin._warned = true;
}
if (plugin.install) {
plugin.install(module);
} else {
Common.warn('Plugin.use:', Plugin.toString(plugin), 'does not specify an install function.');
plugin._warned = true;
}
if (plugin._warned) {
status.push('🔶 ' + Plugin.toString(plugin));
delete plugin._warned;
} else {
status.push('✅ ' + Plugin.toString(plugin));
}
module.used.push(plugin.name);View on GitHub (pinned to acb99b6f87)
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.
Example fix
// before
const plugin = { name: 'p', version: '1.0.0', for: 'other-lib', install() {} };
Plugin.use(Matter, [plugin]); // for-target mismatch
// after
const plugin = { name: 'p', version: '1.0.0', for: 'matter-js@>=0.19.0', install() {} };
Plugin.use(Matter, [plugin]); Defensive patterns
Strategy: validation
Validate before calling
function isForTarget(plugin, moduleName) {
if (!plugin.for) return true;
const target = plugin.for.split('@')[0];
return target === moduleName;
}
if (isForTarget(plugin, 'matter-js')) Matter.Plugin.use(Matter, [plugin]); Type guard
function matchesFor(plugin, module) {
return !plugin.for || plugin.for === module.name ||
String(plugin.for).split('@')[0] === (module.name || 'matter-js');
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Plugin.register: was upgraded to
- Plugin.register: can not be downgraded to
- Plugin.register: does not implement all required fields.
- Plugin.register: is already registered to different plugin o
- Plugin.use: does not specify any dependencies to install.
AI-assisted analysis of liabru/matter-js@acb99b6f87 (2026-09-02).
Data as JSON: /api/errors/72a05fb322db3aaa.
Report an issue: GitHub.