Angular development moves so quickly that there's a really good chance you'll have to troubleshoot your installation. Below are a few common problems I run into all the time.
ng build errors
I received this somewhat cryptic message while trying to run
You have to be inside an angular-cli project in order to use the build command after reinstall of angular-cli
After spending some time digging through StackOverflow I finally figured out how to just re-do the installation.
The conservative approach is to simply uninstall and re-install Angular cli.
Globally remove Angular client.
npm uninstall -g angular-cli @angular/cli
Locally remove your Angular client.
npm uninstall --save angular-cli
Globally re-install the Angular client.
npm install -g @angular/cli@latest
If the conservative approach doesn't work, then this should work 90% of the time. After you uninstall Angular, do a force NPM clean both globally and locally.
Tell Node Package Manager to clean it's cache at the global level.
npm -g cache clean --force
Tell Node Package Manager to clean it's cache at the local level.
npm cache clean --force
Port Already in Use
Port 4200 is already in use. Use '--port' to specify a different port.
If you see this error, run the command below:
sudo lsof -t -i tcp:4200 | xargs kill -9
This command will list out any processes that are using port 4200 and force quit them (aka