Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you specify UI port for lite-server?

Tags:

lite-server

When you start up lite-server, you can specify port for example

lite-server -- port 8000

Which gives you the following result:

[BS] Access URLs:
 ------------------------------------
       Local: http://localhost:8000
    External: http://192.168.0.5:8000
 ------------------------------------
          UI: http://localhost:3001
 UI External: http://192.168.0.5:3001

How can I change the port for UI which is 3001 by default (either command line and/or in bs-config.json file), to like 8001?

like image 756
MrLehiste Avatar asked Feb 19 '16 23:02

MrLehiste


People also ask

What is BS config JSON?

bsconfig. json is the single, mandatory build meta file needed for rescript . The complete configuration schema is here. We'll non-exhaustively highlight the important parts in prose below.

How do I install Lite server on Ubuntu terminal?

Install lite-server. At the command prompt in your lite directory, run: npm init -y. We use npm to initialize an empty project. The -y tells it to just use the defaults for any parameters. To add lite-server to our project we can run: npm install --save-dev lite-server

How do I change the port used by Lite-server?

By default, lite-server uses port 3000. But if you would like to use a different port, you can easily change it. For example, let’s switch it to use port 3001. In your bs-config.json file, change the port to look like this: Restart lite-server using npm start. lite-server launches our default browser again. But, this time the URL looks like this:

What is the config file for Lite-server?

The config file for lite-server is: bs-config.json Why bs-config? Well, lite-server is built on Browsersync which supports having a JSON or JavaScript config file named bs-config. Add a bs-config.json file to the root of your project.

How do I add Lite-server to my project?

To add lite-server to our project we can run: This installs the lite-server package and adds it to the devDependencies in our project’s package.json file. Also, you can take a look at the node_modules folder and see that lite-server and its dependencies are all installed there.


2 Answers

Just to add, for slow thinkers like me, to run lite-server on different port, create file bs-config.json in root of your project (or wherever you are running lite-server from) and add this into your bs-config.json

{
    "port": 8080
}

this will run lite server on port 8080

alternatively you can just pass path of the bs-config.json on running lite-server

lite-server -c configs/my-bs-config.json

source: https://github.com/johnpapa/lite-server#custom-configuration

like image 97
vidriduch Avatar answered Sep 19 '22 04:09

vidriduch


Since lite-server uses browsersync, it can be changed via BrowserSync options

Not sure about command line parameter, but bs-config.json works like this:

{
  "port": 8000,
  "files": ["./dist/**/*.{html,htm,css,js}"],
  "server": { "baseDir": "./" },
  "ui": {
    "port": 8001
  }
}

BrowserSync command line options (that also work with lite-server)

like image 26
MrLehiste Avatar answered Sep 18 '22 04:09

MrLehiste