parcel-bundler/parcel · error · ThrowableDiagnostic
The "global" output format is not supported in the "${target
Error message
The "global" output format is not supported in the "${targetName}" target. What it means
The `global` outputFormat (IIFE-style global assignment) is rejected for the named target. Parcel only supports `global` for the `browser`-style/UMD-like scenarios tied to specific targets, and this guard fires when descriptor.outputFormat === 'global' is set on a target whose configuration disallows it (paired with a code highlight on /targets/<name>/outputFormat).
Source
Thrown at packages/core/core/src/requests/TargetRequest.js:774
]),
},
],
hints: [
`The "${targetName}" field is meant for libraries. If you meant to output a ${ext} file, either remove the "${targetName}" field or choose a different target name.`,
],
documentationURL:
'https://parceljs.org/features/targets/#library-targets',
},
});
}
if (descriptor.outputFormat === 'global') {
let contents: string =
typeof pkgContents === 'string'
? pkgContents
: // $FlowFixMe
JSON.stringify(pkgContents, null, '\t');
throw new ThrowableDiagnostic({
diagnostic: {
message: md`The "global" output format is not supported in the "${targetName}" target.`,
origin: '@parcel/core',
codeFrames: [
{
language: 'json',
filePath: pkgFilePath ?? undefined,
code: contents,
codeHighlights: generateJSONCodeHighlights(contents, [
{
key: `/targets/${targetName}/outputFormat`,
type: 'value',
},
]),
},
],
hints: [
`The "${targetName}" field is meant for libraries. The outputFormat must be either "commonjs" or "esmodule". Either change or remove the declared outputFormat.`,View on GitHub (pinned to 59484858a1)
Solutions
- Switch the target's outputFormat to a supported value (`esmodule`, `commonjs`) or use a target/context that supports `global`.
- If you need a UMD/global browser bundle, ensure the target's env context is browser and remove conflicting options.
- Remove the explicit outputFormat and let Parcel infer it from the target name/extension.
Example fix
// before (package.json)
"targets": {
"main": { "outputFormat": "global" }
}
// after
"targets": {
"main": { "outputFormat": "commonjs" }
} Defensive patterns
Strategy: validation
Validate before calling
function assertOutputFormat(targetName, descriptor) {
if (descriptor.outputFormat === 'global' && !/browser|umd/.test(targetName)) {
throw new Error(`"global" outputFormat not permitted for target ${targetName}`);
}
} Type guard
function allowsGlobalOutputFormat(descriptor) {
return descriptor?.outputFormat !== 'global' || descriptor?.context === 'browser';
} Try / catch
try { await parcel.run(); } catch (e) {
if (/"global" output format is not supported/.test(e.message)) {
console.error('Switch outputFormat to esmodule/commonjs or use a browser target.');
} else throw e;
} Prevention
- Avoid `outputFormat: 'global'` on Node/library targets.
- Use the `module` target for ESM and `main` for CJS instead of forcing global.
- Document which targets permit global format in shared config.
When it happens
Trigger: Setting `"outputFormat": "global"` under `targets.<name>` in package.json for a target that does not permit the global format (e.g. an esmodule/commonjs-only target).
Common situations: Migrating from webpack `libraryTarget: 'global'` and carrying the format over; trying to ship a UMD-ish bundle by hand-configuring global on a target that resolves to a non-browser context.
Related errors
- Unexpected output file type ${ext} in target "${targetName}"
- Declared output format "${descriptor.outputFormat}" does not
- Library targets are not supported in serve mode.
- Scope hoisting cannot be disabled for library targets.
- Invalid distPath for target "${targetName}"
AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13).
Data as JSON: /api/errors/085551825a39df2d.
Report an issue: GitHub.