Thursday, March 16, 2017

Angular CLI - You have to be inside an angular-cli project in order to use the build command

After creating an Angular application using the following Angular CLI command;

ng new appname

You should open the newly created appname folder before invoking any other ng command. Otherwise you get the following error message:

You have to be inside an angular-cli project in order to use the <commandname> command

Unfortunately I got the same error after pulling an Angular project created by a colleague from our GIT repo. Although I was certainly in the correct folder, I saw the above error again Sad smile.

Turned out that the Angular project was created using a newer version of the Angular CLI. After updating to the latest version of the @angular/cli package the problem disappeared.

Remark: Here are the steps to correctly update Angular CLI: https://github.com/angular/angular-cli#updating-angular-cli