{"id":10989,"library":"gulp-live-server","title":"Gulp Live Server","description":"gulp-live-server is a lightweight Gulp plugin designed to provide a development server with integrated live-reloading capabilities for static assets or Node.js applications. It abstracts the complexities of setting up a web server (potentially using `connect` or `express` internally) and a separate LiveReload server (via `tiny-lr`), allowing developers to quickly spin up a server and have their browser automatically refresh upon file changes. The package offers methods for serving static files, running a custom Node.js script as the server, and notifying the browser of updates. Despite its utility, the package is largely unmaintained, with its last release (version 0.0.31) dating back over 7 years to July 2017. Users should be aware of potential compatibility issues with newer Node.js versions or modern Gulp setups, especially those using ES Modules.","status":"abandoned","version":"0.0.31","language":"javascript","source_language":"en","source_url":"git://github.com/gimm/gulp-live-server","tags":["javascript","gulpplugin","server","static","live","livereload","connect","express"],"install":[{"cmd":"npm install gulp-live-server","lang":"bash","label":"npm"},{"cmd":"yarn add gulp-live-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add gulp-live-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This is a Gulp plugin and requires Gulp to define tasks and orchestrate the server setup and watch operations.","package":"gulp","optional":false}],"imports":[{"note":"The package is CommonJS-only. Use `require()` for the main plugin instance.","wrong":"import gls from 'gulp-live-server';","symbol":"gls","correct":"const gls = require('gulp-live-server');"},{"note":"This method creates a server for serving static files. The package does not support ES Module named imports.","wrong":"import { static } from 'gulp-live-server';","symbol":"gls.static","correct":"const server = gls.static('public');"},{"note":"This method starts a server by running a custom Node.js script. The package does not support ES Module named imports.","wrong":"import { new } from 'gulp-live-server';","symbol":"gls.new","correct":"const server = gls.new('myapp.js');"}],"quickstart":{"code":"const gulp = require('gulp');\nconst gls = require('gulp-live-server');\n\ngulp.task('serve-static', function() {\n  // 1. Serve with default settings (serves 'public' folder on port 3000)\n  const server = gls.static();\n  server.start();\n\n  // 2. Serve at a custom port for 'dist' folder\n  const customPortServer = gls.static('dist', 8888);\n  customPortServer.start();\n\n  // 3. Serve multiple folders\n  const multiFolderServer = gls.static(['dist', '.tmp']);\n  multiFolderServer.start();\n\n  // Use gulp.watch to trigger server actions (notify, start or stop)\n  gulp.watch(['static/**/*.css', 'static/**/*.html'], function (file) {\n    server.notify.apply(server, [file]);\n    customPortServer.notify.apply(customPortServer, [file]);\n    multiFolderServer.notify.apply(multiFolderServer, [file]);\n  });\n});\n\n// To run: `gulp serve-static`","lang":"javascript","description":"This quickstart demonstrates how to set up `gulp-live-server` to serve static files from one or multiple directories and configure live-reloading upon file changes."},"warnings":[{"fix":"Ensure your `gulpfile.js` uses CommonJS `require()` syntax. If your project uses ESM for other parts, you may need to keep `gulpfile.js` as a `.js` file without `\"type\": \"module\"` set, or restructure your Gulp setup to handle CJS dependencies.","message":"This package is CommonJS-only and does not support ES Modules. Attempting to import it directly in an ESM context (e.g., `\"type\": \"module\"` in `package.json` or `.mjs` files) will result in import errors.","severity":"breaking","affected_versions":">=0.0.31"},{"fix":"Wrap `server.start.bind(server)` in an anonymous function to ensure correct context: `gulp.watch('myapp.js', function() { server.start.bind(server)() });`.","message":"When restarting the server via `gulp.watch`, directly binding `server.start` might lead to a `TypeError: Bad argument` due to how `ChildProcess.spawn` handles the `this` context.","severity":"gotcha","affected_versions":">=0.0.31"},{"fix":"Evaluate alternative Gulp plugins for live-reloading and static servers, such as `browser-sync` or `gulp-connect`, which are actively maintained and provide similar or enhanced functionality for modern development workflows.","message":"This package is effectively abandoned, with its last release over 7 years ago. It may contain unpatched security vulnerabilities, suffer from compatibility issues with newer Node.js versions or dependencies, and is not actively maintained. Consider modern alternatives.","severity":"gotcha","affected_versions":">=0.0.31"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Wrap the bound function in an anonymous function: `gulp.watch('myapp.js', function() { server.start.bind(server)() });`","cause":"The `server.start` method's `this` context is lost when bound directly in `gulp.watch`.","error":"TypeError: Bad argument at TypeError (native) at ChildProcess.spawn"},{"fix":"Ensure your `gulpfile.js` is a CommonJS file (plain `.js` without `\"type\": \"module\"` in `package.json` or a separate `cjs` folder for Gulp tasks) and use `const gls = require('gulp-live-server');`.","cause":"Attempting to `require()` this CommonJS-only package in an ES Module context (e.g., a file with `\"type\": \"module\"` in `package.json` or a `.mjs` extension).","error":"ERR_REQUIRE_ESM"},{"fix":"Ensure `var gulp = require('gulp');` is present at the top of your `gulpfile.js` and `gulp` is installed as a development dependency (`npm install --save-dev gulp`).","cause":"The `gulp` object was not correctly imported or available in the scope where `gulp-live-server` is used.","error":"ReferenceError: gulp is not defined"}],"ecosystem":"npm"}