angular/angular-cli · error · CommandError
Unable to install packages
Error message
Unable to install packages
What it means
During `ng update`, the package-install task calls the package manager's install(); any failure (network outage, registry auth, lockfile conflicts, disk issues) is swallowed and rethrown as the generic CommandError 'Unable to install packages', hiding the underlying cause.
Source
Thrown at packages/angular/cli/src/commands/update/cli.ts:598
maxRetries: 3,
});
} catch (e) {
assertIsError(e);
if (e.code === 'ENOENT') {
task.skip('Cleaning not required. Node modules directory not found.');
}
}
},
},
{
title: 'Installing packages',
async task() {
try {
await packageManager.install({
ignorePeerDependencies,
});
} catch (e) {
throw new CommandError('Unable to install packages');
}
},
},
]);
try {
await tasks.run();
// Clear Node's module resolution path cache to prevent stale lookups
// when resolving migration package paths.
const Module = require('node:module');
if (Module && Module._pathCache) {
Module._pathCache = Object.create(null);
}
} catch (e) {
if (originalPackageJsonContent !== undefined) {
try {
await fs.writeFile(packageJsonPath, originalPackageJsonContent, 'utf8');
logger.info('Restored package.json to its original state.');
} catch (restoreError) {View on GitHub (pinned to bb72145f9a)
Solutions
- Check network/registry access: `npm ping` / verify .npmrc registry and auth tokens.
- Run `npm install` (or yarn/pnpm) manually in the workspace to see the real error.
- Fix peer dependency conflicts or use --force/--legacy-peer-deps appropriately, then retry ng update.
- Delete node_modules and lockfile issues (`rm -rf node_modules package-lock.json`) and retry.
Example fix
// before (private scope without auth)
ng update @myco/ui
// error: Unable to install packages
// after: add token to .npmrc
// @myco:registry=https://npm.myco.io/
// npm.myco.io/:_authToken=${NPM_TOKEN}
ng update @myco/ui Defensive patterns
Strategy: try-catch
Validate before calling
import { execSync } from 'child_process';
execSync('npm ping'); // fail fast on registry unavailability before ng update
execSync('npm ls --depth=0'); Try / catch
try {
await ngUpdate(packages);
} catch (e) {
if (String(e.message) === 'Unable to install packages') {
console.error('ng update hid the real cause; run npm install manually to see it:', e);
execSync('npm install --verbose', { stdio: 'inherit' });
} else throw e;
} Prevention
- Verify .npmrc registry URL and auth tokens before updating.
- Run installs on a reliable network; avoid VPN/proxy outages in CI.
- Retry manually with the package manager to surface the underlying error ng update hides.
When it happens
Trigger: packageManager.install({ ignorePeerDependencies }) throws — offline machine, private registry requiring auth, unresolved peer dependency conflicts, corrupted node_modules, or npm/yarn/pnpm CLI errors.
Common situations: Corporate proxies/VPNs blocking registry access; missing NPM_TOKEN for @private scopes; partially installed node_modules; incompatible peer dependencies with ignorePeerDependencies=false.
Related errors
- Incompatible peer dependencies found. See above for details.
- Package ${JSON.stringify(name)} was not found in package.jso
- Package ${name} is not installed.
- Repository is not clean. Please commit or stash any changes
- A single package must be specified when using the 'migrate-o
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/69cd9ecae62e002e.
Report an issue: GitHub.