Dawid Dyrcz
Dawid Dyrcz

Reputation: 365

Angular - ng serve vs npm start

I have a little question about angular-cli.

Is it true that when I run ng serve I use the global installed angular-cli and when I run npm start the local one?

Upvotes: 10

Views: 20359

Answers (4)

Mthunzi Desmond
Mthunzi Desmond

Reputation: 11

Yes. It is true. ng serve runs the app on angular global cli on the current version of the installed angular version while npm run start runs it on the version of that particular angular application cloned version from the node-module.

Upvotes: 0

yusuf tezel
yusuf tezel

Reputation: 1282

Yes it is true.

Let's say your global Angular CLI version is 2 and you just cloned and installed a project from github that is created with Angular CLI version 1. If you run ng serve it will execute using version 2 (which is your global cli), if you run npm run start it will use the script in node_modules/.bin folder (which is local to your project and which is the right one for the job).

Upvotes: 3

Er. Bahuguna Goyal
Er. Bahuguna Goyal

Reputation: 192

When you run the npm start internally it will call whatever command is written inside the start in the package.json.

"scripts": {
  "start": "ng serve"
}

it will run the ng serve

For more details, check When to use 'npm start' and when to use 'ng serve'?

Upvotes: 5

Vicky
Vicky

Reputation: 620

Command will decide by package.json . ng serve / npm start is used based on package.json can change form there. if ng serve is not working can use npm start to run server.

ng server :

"scripts": { "ng": "ng", "start": "ng serve", "test": "ng test",....... }

Upvotes: 5

Related Questions