Different ways to run Angular application
How do you run your Angular application during development? Do you know how many ways you can run it? Let’s explore it.
1. `ng serve`
Most of us use the ng serve
command to start the application. Once the application is compiled, the output log shows the URL to launch the application.
ng serve
You can launch the browser by passing — open a parameter as well.
ng serve --open
2. `ng s`
If you are lazy to type the whole serve
word, then you can just use s
instead and start application using ng s
command.
Again, if you would like to open the browser as soon as build is finished, you can pass -o
the flag to launch the browser.
ng s -o
3. npm run start
If you are the person who keep switching between different JavaScript frameworks like Node.js, Angular, React etc. this command is easy to remember. It will fun the underlying command from package.json
file.
npm run start
{
"scripts": {
"start": "ng serve --configuration development",
}
}
4. npm start
Bonus note for lazy developers (like me), to start application just by typing dropping run
word as npm picks up the start
by default.
npm start