When to use 'npm start' and when to use 'ng serve'?

ishandutta2007 picture ishandutta2007 · Oct 22, 2016 · Viewed 168.9k times · Source

ng serve serves an Angular project via a development server

 

npm start runs an arbitrary command specified in the package's "start" property of its "scripts" object. If no "start" property is specified on the "scripts" object, it will run node server.js.

It seems like ng serve starts the embedded server whereas npm start starts the Node servers.

Can someone throw some light on it?

Answer

Puigcerber picture Puigcerber · Oct 22, 2016

npm start will run whatever you have defined for the start command of the scripts object in your package.json file.

So if it looks like this:

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

Then npm start will run ng serve.