{"record":{"id":"5532158624729de2","repo":"angular/angular-cli","slug":"web-worker-requires-a-project-type-of-application","errorCode":null,"errorMessage":"Web Worker requires a project type of \"application\".","messagePattern":"Web Worker requires a project type of \"application\"\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/web-worker/index.ts","lineNumber":81,"sourceCode":"} else {\n  // Web Workers are not supported in this environment.\n  // You should add a fallback so that your program still executes correctly.\n}\n    `;\n\n    // Append the worker creation snippet.\n    const originalContent = host.readText(siblingModulePath);\n    host.overwrite(siblingModulePath, originalContent + '\\n' + workerCreationSnippet);\n\n    return host;\n  };\n}\n\nconst webWorkerSchematic: RuleFactory<WebWorkerOptions> = createProjectSchematic(\n  (options, { project }) => {\n    const projectType = project.extensions['projectType'];\n    if (projectType !== 'application') {\n      throw new SchematicsException(`Web Worker requires a project type of \"application\".`);\n    }\n\n    if (options.path === undefined) {\n      options.path = buildDefaultPath(project);\n    }\n    const parsedPath = parseName(options.path, options.name);\n    options.name = parsedPath.name;\n    options.path = parsedPath.path;\n\n    const templateSourceWorkerCode = apply(url('./files/worker'), [\n      applyTemplates({ ...options, ...strings }),\n      move(parsedPath.path),\n    ]);\n\n    const root = project.root || '';\n    const templateSourceWorkerConfig = apply(url('./files/worker-tsconfig'), [\n      applyTemplates({\n        ...options,","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/web-worker/index.ts#L63-L99","documentation":"Web workers can only be generated in projects whose projectType extension is \"application\". The web-worker schematic checks project.extensions['projectType'] and throws this SchematicsException for libraries or any non-application project, because worker bundling wiring assumes an application build.","triggerScenarios":"Running `ng generate web-worker <name> --project=<name>` where the project's angular.json entry has \"projectType\": \"library\" (or anything other than \"application\").","commonSituations":"Trying to add a web worker inside a library project, an Nx workspace lib, or after hand-editing projectType to a non-standard value.","solutions":["Target an application project instead: `ng g web-worker my-worker --project=my-app`.","If the worker truly belongs to a library, generate it in a consuming application or structure the worker as a plain worker file/lib asset without the schematic.","Check the project's projectType in angular.json; only change it to \"application\" if the project genuinely is one."],"exampleFix":"// before\nng g web-worker app-worker --project=my-lib   // projectType: library\n// after\nng g web-worker app-worker --project=my-app   // projectType: application","handlingStrategy":"validation","validationCode":"const ws = JSON.parse(fs.readFileSync('angular.json', 'utf8'));\nconst projectType = ws.projects?.[name]?.projectType ?? ws.projects?.[name]?.extensions?.projectType;\nif (projectType !== 'application') {\n  throw new Error(`Web workers can only be added to \"application\" projects; \"${name}\" is \"${projectType}\".`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only run `ng generate web-worker` with --project pointing at an application project.","For libraries, emit worker files as assets and instantiate the Worker from the consuming app.","Check \"projectType\" in angular.json before invoking project-type-sensitive schematics."],"tags":["schematics","web-worker","project-type"],"backgroundTag":"unsupported-project-type","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}