{"id":"4d2af64665974d6b","repo":"webpack/webpack","slug":"no-parser-registered-for-type","errorCode":null,"errorMessage":"No parser registered for ${type}","messagePattern":"No parser registered for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/NormalModuleFactory.js","lineNumber":1534,"sourceCode":"\t\treturn /** @type {ParserByType[T]} */ (parser);\n\t}\n\n\t/**\n\t * Creates a parser from the provided type.\n\t * @template {string} T\n\t * @param {T} type type\n\t * @param {ParserOptions} parserOptions parser options\n\t * @returns {ParserByType[T]} parser\n\t */\n\tcreateParser(type, parserOptions = {}) {\n\t\tparserOptions = mergeGlobalOptions(\n\t\t\tthis._globalParserOptions,\n\t\t\ttype,\n\t\t\tparserOptions\n\t\t);\n\t\tconst parser = this.hooks.createParser.for(type).call(parserOptions);\n\t\tif (!parser) {\n\t\t\tthrow new Error(`No parser registered for ${type}`);\n\t\t}\n\t\tthis.hooks.parser.for(type).call(parser, parserOptions);\n\t\treturn /** @type {ParserByType[T]} */ (parser);\n\t}\n\n\t/**\n\t * Returns generator.\n\t * @template {string} T\n\t * @param {T} type type of generator\n\t * @param {GeneratorOptions} generatorOptions generator options\n\t * @returns {GeneratorByType[T]} generator\n\t */\n\tgetGenerator(type, generatorOptions = EMPTY_GENERATOR_OPTIONS) {\n\t\tlet cache = this.generatorCache.get(type);\n\n\t\tif (cache === undefined) {\n\t\t\tcache = new WeakMap();\n\t\t\tthis.generatorCache.set(type, cache);","sourceCodeStart":1516,"sourceCodeEnd":1552,"githubUrl":"https://github.com/webpack/webpack/blob/318421ea8ac81371f5171236a6efb63675576528/lib/NormalModuleFactory.js#L1516-L1552","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the relevant experiment/defaults are enabled (e.g. experiments.css, experiments.assetModule) so webpack registers a parser for the type.","If you introduced a custom type, register a parser via compilation.parserPlugin or normalModuleFactory.hooks.createParser.for(type).tap(...).","Check module.rules 'type' values are spelled exactly as webpack expects."],"exampleFix":"// before\nmodule: { rules: [{ test: /\\.foo$/, type: 'custom/foo' }] }\n// no parser registered for 'custom/foo'\n\n// after\n// register a parser (plugin author), or use a built-in type:\nmodule: { rules: [{ test: /\\.foo$/, type: 'asset/source' }]","handlingStrategy":"validation","validationCode":"/** Check that a module type has a parser before relying on it.\n * @param {import('webpack/lib/NormalModuleFactory')} nmf\n * @param {string} type\n * @returns {boolean} */\nfunction hasParserForType(nmf, type) {\n  // The HookMap exposes taps; if none are registered for `type`, parsing will fail.\n  return nmf.hooks.createParser.for(type).taps.length > 0;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use built-in module types unless you have registered both a parser and generator.","When enabling experiments, confirm the experiment flag registers parsers (e.g. experiments.css).","Spell module.rules 'type' exactly as documented; typos produce unregistered types."],"tags":["parser","module-type","config","experiments"],"analyzedSha":"318421ea8ac81371f5171236a6efb63675576528","analyzedAt":"2026-08-03T19:39:56.731Z","schemaVersion":2}