rollup/rollup · error
Invalid --plugin argument format: ${JSON.stringify(pluginTex
Error message
Invalid --plugin argument format: ${JSON.stringify(pluginText)} What it means
Thrown by the Rollup CLI when the text passed to --plugin/-p does not look like a module specifier, a `name=arg` pair, or an inline object literal. The loader at cli/run/commandPlugins.ts:53 only accepts the regex `/^[\w./:@\\^{|}-]+(=(.*))?$/` once the leading `{` case is ruled out; any character outside that class (spaces, +, %, etc.) makes the argument unparseable.
Source
Thrown at cli/run/commandPlugins.ts:60
async function loadAndRegisterPlugin(
inputOptions: InputOptionsWithPlugins,
pluginText: string
): Promise<void> {
let plugin: any = null;
let pluginArgument: any = undefined;
if (pluginText[0] === '{') {
// -p "{transform(c,i){...}}"
plugin = new Function('return ' + pluginText);
} else {
const match = pluginText.match(/^([\w./:@\\^{|}-]+)(=(.*))?$/);
if (match) {
// -p plugin
// -p plugin=arg
pluginText = match[1];
pluginArgument = new Function('return ' + match[3])();
} else {
throw new Error(`Invalid --plugin argument format: ${JSON.stringify(pluginText)}`);
}
if (!/^\.|^rollup-plugin-|[/@\\]/.test(pluginText)) {
// Try using plugin prefix variations first if applicable.
// Prefix order is significant - left has higher precedence.
for (const prefix of ['@rollup/plugin-', 'rollup-plugin-']) {
try {
plugin = await requireOrImport(prefix + pluginText);
break;
} catch {
// if this does not work, we try requiring the actual name below
}
}
}
if (!plugin) {
try {
if (pluginText[0] == '.') pluginText = path.resolve(pluginText);
// Windows absolute paths must be specified as file:// protocol URL
// Note that we do not have coverage for Windows-only code pathsView on GitHub (pinned to ddc4ffab62)
Solutions
- Remove characters outside [\w./:@\^{|}-] from the plugin argument (most often: stray spaces).
- Pass inline object plugins with a leading brace: -p "{ transform(code, id) { return code } }".
- Pass plugin options via `=`: -p node-resolve={browser:true}.
- Separate multiple plugins with commas: -p node-resolve,commonjs.
- Use a rollup.config.js file instead of -p for non-trivial plugin configuration.
Example fix
// before rollup -p "node resolve" // after rollup -p node-resolve
Defensive patterns
Strategy: validation
Validate before calling
// Reject invalid --plugin text before invoking the CLI loader.
const PLUGIN_SPEC_RE = /^[\w./:@\\^{|}-]+(=(.*))?$/;
function isValidPluginText(text) {
if (typeof text !== 'string' || text.length === 0) return false;
if (text[0] === '{') return true; // inline object plugin
return PLUGIN_SPEC_RE.test(text);
}
if (!isValidPluginText(userPluginArg)) {
throw new Error(`Refusing to run: bad --plugin value ${JSON.stringify(userPluginArg)}`);
} Prevention
- Quote -p arguments to avoid shell splitting on spaces.
- Use rollup.config.js for anything beyond a simple plugin name.
- Separate multiple plugins with commas, not spaces.
- Pass inline plugins with a leading `{` and options via `=`.
When it happens
Trigger: Running `rollup -p "node resolve"` (space), `rollup -p "a+b"`, `rollup -p "foo#bar"`, or any plugin string containing characters outside `[\w./:@\\^{|}-]` that does not start with `{`.
Common situations: Shell quoting mistakes, copy-pasted plugin names with stray spaces, attempting to pass JSON-like option strings without the leading brace, or trying to pass multiple plugins separated by spaces instead of commas.
Related errors
- Cannot load plugin "${pluginText}": ${error.message}.
- Cannot find entry for plugin "${pluginText}". The plugin nee
- You must supply options.input to rollup
- You must supply an options object to rollup
- You must supply an options object
AI-assisted analysis of rollup/rollup@ddc4ffab62 (2026-08-03).
Data as JSON: /data/errors/26023e74aae97c2a.json.
Report an issue: GitHub.