You have to be inside an angular-cli project in order to use the build command after reinstall of angular-cli
Same as John Pankowicz answer, but in my case I had to run
npm install -g @angular/cli@latest
for the versions to match.
npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli
use sudo on Mac/Linux.
Ok, found it.
package.json must contain a dependency to angular-cli.
When I uninstalled my local angular-cli, npm also removed the dependency entry.