{"record":{"id":"aa84bc6f2fe105a9","repo":"angular/angular-cli","slug":"failed-to-clean-up-temporary-dependency-package","errorCode":null,"errorMessage":"Failed to clean up temporary dependency '${packageName}': ${error instanceof Error ? error.message : error}","messagePattern":"Failed to clean up temporary dependency '(.+?)': (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular/cli/src/commands/add/cli.ts","lineNumber":619,"sourceCode":"      const projectManifest = await this.getProjectManifest();\n      if (projectManifest) {\n        if (projectManifest.dependencies) {\n          delete projectManifest.dependencies[packageName];\n        }\n        if (projectManifest.devDependencies) {\n          delete projectManifest.devDependencies[packageName];\n        }\n\n        await fs.writeFile(\n          join(this.context.root, 'package.json'),\n          JSON.stringify(projectManifest, null, 2) + '\\n',\n        );\n      }\n\n      // 2. Silent install pass to prune files from node_modules and update the lockfile\n      await this.context.packageManager.install({ ignoreScripts: true });\n    } catch (error) {\n      this.context.logger.warn(\n        `Failed to clean up temporary dependency '${packageName}': ` +\n          `${error instanceof Error ? error.message : error}`,\n      );\n    }\n  }\n\n  private async installPackageTask(\n    context: AddCommandTaskContext,\n    task: AddCommandTaskWrapper,\n    options: Options<AddCommandArgs>,\n  ): Promise<void> {\n    const { registry } = options;\n    const { packageIdentifier, savePackage } = context;\n    const { packageManager } = this.context;\n\n    // Only show if installation will actually occur\n    task.title = 'Installing package';\n","sourceCodeStart":601,"sourceCodeEnd":637,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/add/cli.ts#L601-L637","documentation":"During `ng add`, the CLI temporarily installs a package to inspect it, then tries to remove it via a silent package-manager install. If that cleanup install fails, this warning is logged. The added package still works; only leftover temporary state may remain.","triggerScenarios":"The silent `packageManager.install({ ignoreScripts: true })` inside cleanUpTemporaryDependency throws — e.g. corrupted lockfile, network/registry outage, or peer-dependency conflicts when pruning the temp dependency.","commonSituations":"Offline or flaky npm/yarn/pnpm/bun registry access; a package whose removal conflicts with existing peer dependencies; npm cache corruption; scripts disabled by a misconfigured .npmrc.","solutions":["Run the package manager install manually (`npm install`) to restore a consistent node_modules/lockfile.","Check registry connectivity and proxy settings.","Delete node_modules and the lockfile, then reinstall.","Inspect package.json/lockfile for leftover temporary dependency entries and remove them."],"exampleFix":"// before (manual cleanup fails silently)\n// after\nrm -rf node_modules package-lock.json && npm install","handlingStrategy":"retry","validationCode":"const ok = await pm.install({ dryRun: true }); if (!ok) { await exec('npm install'); }","typeGuard":"function isErr(e: unknown): e is Error { return e instanceof Error; }","tryCatchPattern":"try { await pm.install({ ignoreScripts: true }); } catch (e) { logger.warn(`cleanup failed: ${e instanceof Error ? e.message : e}`); await exec('npm install'); }","preventionTips":["Keep a stable network/registry connection during ng add.","Avoid hand-editing the lockfile while running CLI installs.","Periodically run npm cache verify.","Commit a consistent package.json + lockfile."],"tags":["package-manager","cleanup","ng-add"],"backgroundTag":"package-install-failed","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}