![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
live-server
Advanced tools
This is a little development server with live reload capability. Use it for hacking your HTML/JavaScript/CSS files, but not for deploying the final site.
There are two reasons for using this:
file://
protocol due to security restrictions, i.e. you need a server if your site fetches content through JavaScript.If you don't want/need the live reload, you should probably use something simpler, like the following Python-based one-liner:
python -m SimpleHTTPServer
You need node.js and npm. You should probably install this globally.
Npm way
npm install -g live-server
Manual way
git clone https://github.com/tapio/live-server
cd live-server
npm install # Local dependencies if you want to hack
npm install -g # Install globally
Issue the command live-server
in your project's directory. Alternatively you can add the path to serve as a command line parameter.
This will automatically launch the default browser (you should have index.html
present). When you make a change to any file, the browser will reload the page - unless it was a CSS file in which case the changes are applied without a reload.
Command line parameters:
--port=NUMBER
- select port to use (can also be done with PORT environment variable)--host=ADDRESS
- select host address to bind to, default: 0.0.0.0 ("any address")--no-browser
- suppress automatic web browser launching--browser=BROWSER
- specify browser to use instead of system default--quiet
- suppress logging--open=PATH
- launch browser to PATH instead of server root--ignore=PATH
- comma-separated string of paths to ignore--entry-file=PATH
- serve this file in place of missing files (useful for single page apps)--mount=ROUTE:PATH
- serve the paths contents under the defined route (multiple definitions possible)--wait=MILLISECONDS
- wait for all changes, before reloading--help | -h
- display terse usage hint and exit--version | -v
- display version and exitDefault options:
If a file ~/.live-server.json
exists it will be loaded and used as default options for live-server on the command line. See "Usage from node" for option names.
var liveServer = require("live-server");
var params = {
port: 8181, // Set the server port. Defaults to 8080.
host: "0.0.0.0", // Set the address to bind to. Defaults to 0.0.0.0.
root: "/public", // Set root directory that's being server. Defaults to cwd.
open: false, // When false, it won't load your browser by default.
ignore: 'scss,my/templates', // comma-separated string for paths to ignore
file: "index.html", // When set, serve this file for every 404 (useful for single-page applications)
wait: 1000 // Waits for all changes, before reloading. Defaults to 0 sec.
mount: [['/components', './node_modules']] // Mount a directory to a route.
};
liveServer.start(params);
Open your browser's console: there should be a message at the top stating that live reload is enabled. Note that you will need a browser that supports WebSockets. If there are errors, deal with them. If it's still not working, file an issue.
The server is a simple node app that serves the working directory and its subdirectories. It also watches the files for changes and when that happens, it sends a message through a web socket connection to the browser instructing it to reload. In order for the client side to support this, the server injects a small piece of JavaScript code to each requested html file. This script establishes the web socket connection and listens to the reload requests.
We welcome contributions! See CONTRIBUTING.md for details.
--mount=ROUTE:PATH
cli option to specify alternative routes to paths (@pmentz)--browser=BROWSER
cli option to specify browser to use (@sakiv)~/.live-server.json
if exists (@mikker)--port=0
to select random port (@viqueen)--version / -v
command line flags to display version--host
cli option to mirror the API parameter--ignore=PATH
cli option to not watch given server root relative paths (@richardgoater)--entry-file=PATH
cli option to specify file to use when request is not found (@izeau)--wait=MSECS
cli option to wait specified time before reloading (@leolower, @harrytruong)</body>
logLevel
parameter in library to control amount of console spam--quiet
cli option to suppress console spam--open=PATH
cli option to launch browser in specified path instead of root (@richardgoater)noBrowser: true
option is deprecated in favor of open: false
--no-browser
command line flag to suppress browser launch--help
command line flag to display usagelive-server --port=3000
(@Pomax)send
watchr
> 2.3.3Uses MIT licensed code from Connect and Roots.
(MIT License)
Copyright (c) 2012 Tapio Vierros
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
simple development http server with live reload capability
The npm package live-server receives a total of 64,194 weekly downloads. As such, live-server popularity was classified as popular.
We found that live-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.