How to serve angular2 app without browsersync
Asked Answered
A

3

7

In my package.json I have the following:

...
"scripts": {
        "tsc": "tsc",
        "tsc:w": "tsc -w --outDir build",
        "lite": "lite-server",
        "start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
    },
...

and I was wondering how could I start the app using "npm production" or something similar?

I'd want to prevent browsersync from running: I just tried with multiple users and it was hilarious to see that they were scrolling "as one". This also happens accross different browsers (but not using different tabs).

Acis answered 13/4, 2016 at 14:16 Comment(0)
B
9

You could use serve instead of lite-server.

Bombazine answered 13/4, 2016 at 15:29 Comment(5)
I did npm install --save serve and added the line "serve": "serve", under "scripts" in package.json. Then I was able to use npm run serve.Acis
@PascalvKooten You can also install serve globally so that you do not have to keep a local copy in every project of yours. For this package, you will not require different versions across multiple projects.Cormophyte
How to run it without node or npm or browser-sync??Limicoline
you should use another web server if don't want to use node and npmBombazine
But with npm serve, when i refresh none-root pages, it's a 404.Sejm
B
1

Use the npm start. In newly installed Angular app with ng new <name_of_app>, the package.json file has the settings for that

"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  }

So using npm start will run ng serve and the browser sync does not run browsersync

Blum answered 27/4, 2017 at 11:21 Comment(0)
O
-1

you can use http-server (npm install -g http-server) then in your project directory http-serve -p [port]

Obellia answered 3/11, 2016 at 13:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.