Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing "ng serve" or "npm start" command browser is not opening automatically

Tags:

npm

angular

I have generated a project using angular-cli by following steps given in installation section. Project is running right now. But i have to open browser manually by typing http://localhost:4200/ into browser.

Could it be possible like when user will execute "ng serve" or "npm start" command, browser will open automatically?

Please let me know if it is possible or give me any solution for this.

like image 1000
Chanaka Amarasinghe Avatar asked Mar 22 '17 05:03

Chanaka Amarasinghe


People also ask

How do I start NPM from a browser window?

Just go into your package.json, and add the -o flag. Now when you do npm start, it'll open up the browser window and right port for you and save you a few strokes on the keyboard. Sorry, something went wrong. after changing from "start": "ng serve" to "start": "ng serve -o", it worked for me.

What happens if NPM doesn’t have the start command?

When your package.json file doesn’t have the start command under the scripts property, then NPM will run node server.js instead. When you run the npm start command, you may encounter an error saying that the start script is missing:

Does Ng serve--open open a new tab?

READ THE DOCUMENTATION: Sorry, something went wrong. Sorry, something went wrong. ng serve --open doesn't open any browser nor a new tab in an open browser, nor open the URL in an existing tab. Chrome is my default Windows 7 Pro 64-bit browser.

How to open URL in default browser using Ng serve?

Per the documentation you can use a flag with ng serve: --open ( -o) Opens the url in default browser. You may need update your version for this functionality, as the revision history of the wiki page suggests it's a recent addition.


1 Answers

Per the documentation you can use a flag with ng serve:

--open (-o) Opens the url in default browser.

You may need update your version for this functionality, as the revision history of the wiki page suggests it's a recent addition.

like image 126
jonrsharpe Avatar answered Nov 08 '22 13:11

jonrsharpe