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?
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.
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
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:
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.
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.
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
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)
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