Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

ng fails with Cannot find module @angular/cli/bin/ng

ErrorCannot find module '@angular/cli/bin/ng'

Short answer

The ng command is the entry point to the Angular CLI package. This error means the package it points to is missing: the project's node_modules was never installed or is incomplete, or the global CLI install is broken. Run npm install in the project, or reinstall the CLI globally.

  • Applies to Angular CLI 19, Node.js 22, npm 10
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask npm which Angular CLI the project itself has. If it is missing here, the project install is the problem; if it is present, look at the global install.

    npm ls @angular/cli
    node --version
  2. 2Match what you see, then jump to its fix

    1. 1A fresh clone, a copied folder, or node_modules was deletedThe project dependencies are not installedFix
    2. 2ng fails in every folder, including outside a projectThe global Angular CLI install is broken or missingFix

What does the error look like?

  • Cannot find module '@angular/cli/bin/ng'

Cause 1 of 2

The project dependencies are not installed

1Check

A workspace made with ng new lists @angular/cli as a dependency, because it holds the binary for ng commands. Without node_modules the binary is not there.

ls node_modules/@angular/cli 2>&1 | head -3

2Fix

Install the dependencies listed in package.json, then run the local CLI through npx, which puts locally installed bins on PATH.

npm install
npx ng version

3Verify

The version banner prints.

npx ng version

Confirmed by angular.dev

Did this fix it?

Cause 2 of 2

The global Angular CLI install is broken or missing

1Check

List the globally installed packages. If @angular/cli is not listed, or the listing shows it as broken, the global ng command has nothing valid to load.

npm ls -g @angular/cli

2Fix

Install the CLI again globally. On Unix-like systems a permission error can be solved with sudo, but understand the implications of running as root first.

npm install -g @angular/cli

3Verify

ng runs from any folder.

ng version

Confirmed by angular.dev

Did this fix it?

How do I stop it coming back?

  • Run ng through npx or an npm script so the project's own CLI version is used.
  • Use a Node.js version Angular supports: it requires an active LTS or maintenance LTS release.
  • Do not copy node_modules between machines; reinstall from package.json.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.