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.
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.
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:
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With