Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why npm install -g @angular/cli?

I know there are lot many question regarding this npm package installing but I couldn't find the exact relevant answer, I have already installed npm and also developed few applications in my VStudio, Every time before developing the new project of angular do we need to install npm again by typing this in cmd "npm install -g @angular/cli?

like image 410
Juke Avatar asked Feb 16 '18 14:02

Juke


People also ask

What is npm install Angular CLI?

The Angular Framework, Angular CLI, and components used by Angular applications are packaged as npm packages and distributed using the npm registry. You can download and install these npm packages by using the npm CLI client, which is installed with and runs as a Node. js® application.

Can we install Angular CLI without npm?

Installing Angular CLI on Windows First, you need to have Node and npm installed on your development machine. There are many ways to do that, such as: using NVM (Node Version Manager) for installing and working with multiple versions of node in your system. using the official package manager of your operating system.

Do I need to install Angular CLI?

It's required to install locally because to your project, some specific @angular/cli version is required and newer versions maybe brake. 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.

What is the need of Angular CLI?

The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications directly from a command shell.


2 Answers

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', than 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 brake.

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.

Resume: after installed using npm install -g @angular/cli, you will need just to run ng new app-name.

like image 131
Christian G Fritsch Avatar answered Nov 15 '22 23:11

Christian G Fritsch


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 propertly

like image 45
David Anthony Acosta Avatar answered Nov 15 '22 23:11

David Anthony Acosta