Skip to content

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

Closed

Description

@deepaksibar
  1. OS?
    Window 7
  2. Versions?
    angular-cli: 0.0.39
    node: 5.4.1
    os: win32 x64

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.

Thanks in advance.

-Deepak

Activity

  1. Trendy commented on Jun 14, 2016

    @Trendy

    I don't think the intention is to open the browser automatically. When you visit the URL (http://localhost:4200) the browser should be refreshed automatically when changes occur in the code.

  2. filipesilva commented on Jun 17, 2016

    @filipesilva
    Contributor

    We don't have this functionality at the moment, no. But I'll leave the issue open as a 'nice to have'.

  3. added
    P5The team acknowledges the request but does not plan to address it, it remains open for discussion
    on Jun 17, 2016
  4. Splaktar commented on Jun 18, 2016

    @Splaktar
    Contributor

    Yes, it would be nice to have this as an option.

  5. deepaksibar commented on Jun 18, 2016

    @deepaksibar
    Author

    Thanks for response.
    On 17-Jun-2016 6:24 am, "Filipe Silva" notifications@github.com wrote:

    We don't have this functionality at the moment, no. But I'll leave the
    issue open as a 'nice to have'.

    —
    You are receiving this because you authored the thread.
    Reply to this email directly, view it on GitHub
    #1081 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe/AQPGGMs-Ca05hHGeMFm_V1ZMdjVUvNFEks5qMfAngaJpZM4I1YYs
    .

  6. kamran-pervaiz commented on Jun 23, 2016

    @kamran-pervaiz

    can we not use lite-server written by john papa to open the browser after ng server on inside ng serve

  7. deepaksibar commented on Jun 27, 2016

    @deepaksibar
    Author

    There may be ambiguity between lite-server port and ng server port.

  8. rburnham52 commented on Jul 6, 2016

    @rburnham52

    I don't think the intention is to open the browser automatically. When you visit the URL (http://localhost:4200) the browser should be refreshed automatically when changes occur in the code.

    @Trendy I would consider them 2 different features. The way i have seen the Refresh work is that you hit your site, the site has some javascript injected into it that listens for a command to tell it that something changed then it reloads the page. This is different from when you start the app sending a command to launch a browser and navigate to the URL.

    If you never navigated to the url of your app then there would be no code running to listen when something changed. I guess its still doable but then you would probably need a browser plugin to listen instead

  9. deepaksibar commented on Sep 18, 2016

    @deepaksibar
    Author

    Thanks

    On 18-Sep-2016 2:12 pm, "Chris Foster" notifications@github.com wrote:

    You can just change what npm start does in the package.json.

    E.g. change
    "start": "ng serve"
    to
    "start": "start http://localhost:4201 & ng serve -port 4201"
    (for windows)

    See http://stackoverflow.com/a/35261624 for Mac/Linux equivalents.

    Or you could use the following if you want a cross platform
    https://www.npmjs.com/package/open

    —
    You are receiving this because you authored the thread.
    Reply to this email directly, view it on GitHub
    #1081 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe-auth/AQPGGLV_2xsh-qCSyJGUESUorsOuBj3dks5qrPldgaJpZM4I1YYs
    .

  10. added 4 commits that reference this issue on Oct 3, 2016
    f29c264
    24ba158
    bdede2b
    b38438f
  11. 10 remaining items

  12. kamlesh131986 commented on Jun 20, 2017

    @kamlesh131986

    I have resolved issue. Issue is default browser. you can set browser help below image and run command ng serve --open.

    image

  13. rsprince commented on Jun 20, 2017

    @rsprince

    As I mentioned, the functionality is there. There are a bunch of options on the serve command. READ THE DOCUMENTATION:
    ng serve --open
    OR
    ng serve -o

  14. neapi666 commented on Aug 26, 2017

    @neapi666

    Para que la ejecución sea automática es necesario ejecutar >ng serve -o

  15. davehoo commented on Sep 28, 2017

    @davehoo

    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.

    The instructions say "Using the --open (or just -o) option will automatically open your browser on http://localhost:4200/.", so I'm not sure what's meant by "open", and I've never heard it to mean "refresh" (which sounds like a misnomer a non-IT person would use).

    Has this command ever actually opened a browser or a new tab, or opened the URL in an existing tab? What is this option actually programmed to do?

  16. filipesilva commented on Oct 2, 2017

    @filipesilva
    Contributor

    @dhinged this command has worked for a while now, and it still seems to work as I've just tried it. I wonder why it doesn't work for you... for reference the library we use to open the browser is https://www.npmjs.com/package/opn.

  17. davehoo commented on Oct 8, 2017

    @davehoo

    I apologize, trying it again today, it just took a while for the server to "boot up" but it did open a browser tab (after I'd opened it myself based on the instructions URL).

    So basically I ran the command (either time), it looked like it was running, but there was no output for maybe 15 seconds so I figured it was just running. I then later noticed a ton of output from node, so I just need to wait. However it would be nice to initially see output saying "Starting up" or something indicating it's running but still processing.

    Thanks for being there!

  18. kamok commented on Oct 16, 2017

    @kamok

    Just go into your package.json, and add the -o flag.
    For example:
    "start": "ng serve -o",
    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.

  19. nirmalmohanty91 commented on Jan 18, 2018

    @nirmalmohanty91

    after changing from "start": "ng serve" to "start": "ng serve -o", it worked for me.

  20. nitanshu1808 commented on Feb 13, 2018

    @nitanshu1808

    Hi
    I am not able to create angular js application(LINUX- UBUNTU 16) as every time i try to run it ng it opens a text editor in the terminal
    --**-Mg: scratch (fundamental)----All-----------------

    Can anyone please help me in creating a angular js application in ubuntu.

  21. gcascbt commented on Feb 27, 2018

    @gcascbt

    Hi
    i am unable to get any visible content display after connecting my app with angular2 firebase. its show blank page on the browser and successfully compiled
    error

  22. rsprince commented on Feb 27, 2018

    @rsprince
  23. abhinandanmadaan commented on Mar 18, 2019

    @abhinandanmadaan

    Hi
    I am not able to create angular js application(LINUX- UBUNTU 16) as every time i try to run it ng it opens a text editor in the terminal
    --**-Mg: scratch (fundamental)----All-----------------

    Can anyone please help me in creating a angular js application in ubuntu.

    I'm facing the same problem. Could you resolve the issue?

  24. angular-automatic-lock-bot commented on Sep 9, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  25. locked and limited conversation to collaborators on Sep 9, 2019
  26. added a commit that references this issue on May 29, 2026
    9224665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions