webpack/webpack · error · Error

No parser registered for ${type}

Error message

No parser registered for ${type}

What it means

NormalModuleFactory.createParser asks the createParser HookMap for a parser for the given module type; if no tap registered a parser for that type, it returns undefined and createParser throws 'No parser registered for <type>'. Parsers handle turning source into the dependency graph (e.g. javascript/esm for JS).

Source

Thrown at lib/NormalModuleFactory.js:1534

		return /** @type {ParserByType[T]} */ (parser);
	}

	/**
	 * Creates a parser from the provided type.
	 * @template {string} T
	 * @param {T} type type
	 * @param {ParserOptions} parserOptions parser options
	 * @returns {ParserByType[T]} parser
	 */
	createParser(type, parserOptions = {}) {
		parserOptions = mergeGlobalOptions(
			this._globalParserOptions,
			type,
			parserOptions
		);
		const parser = this.hooks.createParser.for(type).call(parserOptions);
		if (!parser) {
			throw new Error(`No parser registered for ${type}`);
		}
		this.hooks.parser.for(type).call(parser, parserOptions);
		return /** @type {ParserByType[T]} */ (parser);
	}

	/**
	 * Returns generator.
	 * @template {string} T
	 * @param {T} type type of generator
	 * @param {GeneratorOptions} generatorOptions generator options
	 * @returns {GeneratorByType[T]} generator
	 */
	getGenerator(type, generatorOptions = EMPTY_GENERATOR_OPTIONS) {
		let cache = this.generatorCache.get(type);

		if (cache === undefined) {
			cache = new WeakMap();
			this.generatorCache.set(type, cache);

View on GitHub (pinned to 318421ea8a)

Solutions

  1. Ensure the relevant experiment/defaults are enabled (e.g. experiments.css, experiments.assetModule) so webpack registers a parser for the type.
  2. If you introduced a custom type, register a parser via compilation.parserPlugin or normalModuleFactory.hooks.createParser.for(type).tap(...).
  3. Check module.rules 'type' values are spelled exactly as webpack expects.

Example fix

// before
module: { rules: [{ test: /\.foo$/, type: 'custom/foo' }] }
// no parser registered for 'custom/foo'

// after
// register a parser (plugin author), or use a built-in type:
module: { rules: [{ test: /\.foo$/, type: 'asset/source' }]
Defensive patterns

Strategy: validation

Validate before calling

/** Check that a module type has a parser before relying on it.
 * @param {import('webpack/lib/NormalModuleFactory')} nmf
 * @param {string} type
 * @returns {boolean} */
function hasParserForType(nmf, type) {
  // The HookMap exposes taps; if none are registered for `type`, parsing will fail.
  return nmf.hooks.createParser.for(type).taps.length > 0;
}

Prevention

When it happens

Trigger: A module reaching the factory whose type string (e.g. 'json', 'css/auto', 'webassembly/async') has no matching createParser tap. Common when a custom module type or asset experiment is misconfigured. The throw is at NormalModuleFactory.js:1534.

Common situations: Enabling experiments (css, asset, wasm) without the matching default registration; disabling/overriding parser registration; custom module types introduced by a plugin that did not register a parser; mismatch between module.type produced by one plugin and parser type expected by another.

Related errors


AI-assisted analysis of webpack/webpack@318421ea8a (2026-08-03). Data as JSON: /data/errors/4d2af64665974d6b.json. Report an issue: GitHub.