Juke
Juke

Reputation: 1436

Why is it 'npm install -g @angular/cli'?

I know there are a lot of questions regarding this npm package installing, but I couldn't find the exact relevant answer.

I have already installed npm and also developed a few applications in my Visual Studio. Every time, before developing the new project of Angular, do we need to install npm again by typing "npm install -g @angular/cli" in cmd?

Upvotes: 21

Views: 63309

Answers (2)

David Anthony Acosta
David Anthony Acosta

Reputation: 4908

No. You only need to run

npm i -g @angular/cli

Once ever (or when you update in the future).

And that's used to generate Angular apps and different Angular CLI-related terminal commands. You don't need to run it ever again after that. But you will need to install it locally in your project, so that certain things will work properly.

Upvotes: 12

Christian G Fritsch
Christian G Fritsch

Reputation: 578

Once you have installed @angular/cli globally, in the next project you just need run ng new app-name. This command will create a folder named 'app-name' and then will install all dependencies locally, including @angular/cli.

Installing @angular/cli globally allow you to use 'ng' command everywhere. It's required to install locally, because to your project, some specific @angular/cli version is required and newer versions maybe break.

If your @angular/cli global is newer than the local project version, 'ng' will use the local @angular/cli instead, when you run 'ng serve', for example.

Résumé: after installing using npm install -g @angular/cli, you will need just to run ng new app-name.

Upvotes: 27

Related Questions