{"record":{"id":"9b2e2bc6ec560398","repo":"angular/angular-cli","slug":"filepath-resourcetype-or-data-must-be-speci","errorCode":null,"errorMessage":"\"filePath\", \"resourceType\" or \"data\" must be specified.","messagePattern":"\"filePath\", \"resourceType\" or \"data\" must be specified\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ngtools/webpack/src/resource_loader.ts","lineNumber":143,"sourceCode":"    } = webpack;\n\n    const getEntry = (): string => {\n      if (filePath) {\n        return `${filePath}?${NG_COMPONENT_RESOURCE_QUERY}`;\n      } else if (resourceType) {\n        return (\n          // app.component.ts-2.css?ngResource!=!@ngtools/webpack/src/loaders/inline-resource.js!app.component.ts\n          `${containingFile}-${this.outputPathCounter}.${fileExtension}` +\n          `?${NG_COMPONENT_RESOURCE_QUERY}!=!${this.inlineDataLoaderPath}!${containingFile}`\n        );\n      } else if (data) {\n        // Create a special URL for reading the resource from memory\n        return `angular-resource:${resourceType},${createHash('xxhash64')\n          .update(data)\n          .digest('hex')}`;\n      }\n\n      throw new Error(`\"filePath\", \"resourceType\" or \"data\" must be specified.`);\n    };\n\n    const entry = getEntry();\n\n    // Simple sanity check.\n    if (filePath?.match(/\\.[jt]s$/)) {\n      throw new Error(\n        `Cannot use a JavaScript or TypeScript file (${filePath}) in a component's styleUrls or templateUrl.`,\n      );\n    }\n\n    const outputFilePath =\n      filePath ||\n      `${containingFile}-angular-inline--${this.outputPathCounter++}.${\n        resourceType === 'template' ? 'html' : 'css'\n      }`;\n    const outputOptions = {\n      filename: outputFilePath,","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/ngtools/webpack/src/resource_loader.ts#L125-L161","documentation":"The resource loader builds a unique entry key for each resource from either a filePath, or from in-memory `data` combined with a resourceType (template/style). If none of these are supplied there is no way to identify or locate the resource, so it throws.","triggerScenarios":"Calling `get(filePath)` with an empty/undefined path, or `compilationResult()`/`entry` without any of: `filePath`, `resourceType`+`data`. E.g. `entry({ data: '<h1>x</h1>' })` without resourceType, or `entry({})`.","commonSituations":"Programmatic use of the loader API where options are built dynamically and end up undefined; passing an empty string (falsy) as filePath while forgetting data/resourceType; wiring custom loaders with incomplete option objects.","solutions":["Pass a valid `filePath` string when loading a real file resource","When compiling in-memory content, pass BOTH `data` and `resourceType` ('style' or 'template') plus `containingFile`","Log/inspect the options object before calling to confirm none of the required fields are undefined/null","Fix the calling code that builds the options (e.g. unresolved variable, wrong destructure)"],"exampleFix":"// before\nloader.entry({ data: '<h1>hi</h1>' });\n// after\nloader.entry({ data: '<h1>hi</h1>', resourceType: 'template', containingFile: './app.component.ts' });","handlingStrategy":"validation","validationCode":"function assertEntryOptions(opts = {}) {\n  const hasFile = typeof opts.filePath === 'string' && opts.filePath.length > 0;\n  const hasData = opts.data != null && !!opts.resourceType;\n  if (!hasFile && !hasData) throw new Error('Provide filePath, or data + resourceType');\n  return opts;\n}\nloader.entry(assertEntryOptions(options));","typeGuard":"function hasValidEntry(o): o is { filePath: string } | { data: string; resourceType: 'style'|'template' } {\n  return (typeof o?.filePath === 'string' && o.filePath !== '') ||\n    (typeof o?.data === 'string' && (o?.resourceType === 'style' || o?.resourceType === 'template'));\n}","tryCatchPattern":"try {\n  return loader.entry(options);\n} catch (e) {\n  if (e.message.includes('\"filePath\", \"resourceType\" or \"data\" must be specified')) {\n    console.error('Incomplete resource entry options:', options);\n  }\n  throw e;\n}","preventionTips":["Validate options objects before passing them to entry()/compilationResult()","Never pass an empty string as filePath — it is falsy and counts as missing","When using in-memory data, always set resourceType and containingFile"],"tags":["validation","arguments","angular","webpack"],"backgroundTag":"missing-required-argument","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}