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

  1. Correct plugin.for to match the module you install on (e.g. 'matter-js' with a suitable version range like '>=0.14.0').
  2. Install the plugin on the module it declares: Plugin.use(window.Matter, [plugin]) instead of a custom module.
  3. Remove/blank the plugin.for field if the plugin is actually generic.
  4. 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

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


AI-assisted analysis of liabru/matter-js@acb99b6f87 (2026-09-02). Data as JSON: /api/errors/72a05fb322db3aaa. Report an issue: GitHub.