{"record":{"id":"d056f73fb69ab4fa","repo":"angular/angular-cli","slug":"invalid-package-name","errorCode":null,"errorMessage":"Invalid package name","messagePattern":"Invalid package name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/architect/testing/testing-architect-host.ts","lineNumber":46,"sourceCode":"  ) {}\n\n  addBuilder(\n    builderName: string,\n    builder: Builder,\n    description = 'Testing only builder.',\n    optionSchema: json.schema.JsonSchema = { type: 'object' },\n  ): void {\n    this._builderImportMap.set(builderName, builder);\n    this._builderMap.set(builderName, { builderName, description, optionSchema });\n  }\n  async addBuilderFromPackage(packageName: string): Promise<void> {\n    const packageJson = await import(packageName + '/package.json');\n    if (!('builders' in packageJson)) {\n      throw new Error('Invalid package.json, builders key not found.');\n    }\n\n    if (!packageJson.name) {\n      throw new Error('Invalid package name');\n    }\n\n    const builderJsonPath = packageName + '/' + packageJson['builders'];\n    const builderJson = await import(builderJsonPath);\n    const builders = builderJson['builders'];\n    if (!builders) {\n      throw new Error('Invalid builders.json, builders key not found.');\n    }\n\n    for (const builderName of Object.keys(builders)) {\n      const b = builders[builderName];\n      // TODO: remove this check as v1 is not supported anymore.\n      if (!b.implementation) {\n        continue;\n      }\n      const handler = (await import(builderJsonPath + '/../' + b.implementation)).default;\n      const optionsSchema = await import(builderJsonPath + '/../' + b.schema);\n      this.addBuilder(`${packageJson.name}:${builderName}`, handler, b.description, optionsSchema);","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/architect/testing/testing-architect-host.ts#L28-L64","documentation":"After loading the package.json, addBuilderFromPackage() reads packageJson.name to register builders under it. If the field is missing or empty, the host throws 'Invalid package name'.","triggerScenarios":"addBuilderFromPackage(packageName) resolving to a package.json that lacks a non-empty 'name' field.","commonSituations":"Hand-crafted or generated test fixtures where package.json was created without a name; minimally scaffolded packages in temp directories used in tests.","solutions":["Add a \"name\" field to the package's package.json.","Make sure you are importing the intended package, not a stub fixture missing metadata.","If the package is yours, ensure npm metadata wasn't stripped during packaging."],"exampleFix":"// before (package.json)\n{ \"builders\": \"./builders.json\" }\n// after\n{ \"name\": \"@myorg/builders\", \"builders\": \"./builders.json\" }","handlingStrategy":"validation","validationCode":"const pkg = require(packageName + '/package.json');\nif (!pkg.name) {\n  throw new Error(`${packageName}'s package.json is missing a name field`);\n}\nawait architectHost.addBuilderFromPackage(packageName);","typeGuard":"function hasValidName(pkg: object): pkg is { name: string } {\n  return typeof (pkg as any).name === 'string' && (pkg as any).name.length > 0;\n}","tryCatchPattern":"try {\n  await architectHost.addBuilderFromPackage(packageName);\n} catch (e) {\n  if (e.message === 'Invalid package name') {\n    throw new Error(`Fix package.json of ${packageName}: missing \"name\"`);\n  }\n  throw e;\n}","preventionTips":["Never generate test fixture packages without a name field.","Run `npm pkg get name` to sanity-check packages used in tests.","Validate fixture package.json against a schema in test setup."],"tags":["angular-devkit","builders","package-json","configuration"],"backgroundTag":"missing-package-json-key","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}