I am trying to build an Angular 2 application using VSCode editor. On my machine the default browser is IE. When I run npm start it launches the application in IE. But I want to launch my application in Chrome.
How can I change this behaviour to launch Chrome instead of IE with npm start?
You could try it using package.json, as a workaround for default browser. Look into the "scripts" and find "start". Use this code snippet:
"start": "start {browser} http://{projectsite} && ng serve"
With {browser} as your preferred browser (in this case, use chrome), and {projectsite} as the site where the application is started (if you haven't changed any of the setting for the test, still use localhost:4200).
If you want to test it, use npm start to run these commands. It should start the browser first before compiling the angular project so you would see a "page not found" before switching to your app.
If you're using VS_Code as your IDE then go to .vs > vscode > launch.json in that check for the below.
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:PortNo",
"webRoot": "${workspaceFolder}",
}
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