Short Answer / TLTR
Start your project by specifying the package -p @angular/cli, so node can find the program:
npx -p @angular/cli ng new <project-name>
Long Answer
The npm ecosystem has been moving more and more towards installing tools as project-local devDependencies, instead of requiring users to install them globally. This is considered a good practice. As it allows to use multiple versions (one per project), instead of having one unique global version.
In order to start the project from scratch, you need to point to the package with -p flag (otherwise npx will not find it):
npx -p @angular/cli ng new <project-name>
- npx
npx is a command that is installed together with node and npm, starting version 5.2 (July 2017). Most probably you already have it installed.
npx allows you to run that npm command without having it installed locally. npx will look for the latest version of the specified package (in this case @angular/cli) and run the command ng from the bin folder.
- specific versions
You could also install a specific version of Angular CLI. For example, let's say we need to install version 9.1. We could run:
npx -p @angular/[email protected] ng new <project-name>
- once it is installed
After the Angular CLI installs the project, go to the folder and use the npx ng directly. For example:
npx ng serve
This will search inside the node_modules/.bin/ folder for the ng command, which is a soft link pointing to ../@angular/cli/bin/ng, the locally installed ng command.
Links
ng xxxinstead of./node_modules/.bin/ng xxx.@angular/cli. You only need the global import forngcommands to work everywhere and directly, rather than only vianode_modules/.bin. When you check out an existing project, you could just alias everything via thepackage.json.inline code); and 2. that simply isn't the name of the framework. And again please note thatangular-cliis the old, deprecated name of the package.