Registry / devops / gulp-websocket-server

gulp-websocket-server

JSON →
library1.1.2jsnpmunverified

gulp-websocket-server is a Gulp plugin that opens a WebSocket server (using the `ws` library) and sends messages to connected clients when file changes are detected via Gulp streams. Version 1.1.2 (latest) is stable but has not seen updates since 2017; it is in maintenance mode. Key differentiator: built-in integration with Gulp's pipe system via a `livereload` method, plus a standalone `send` method. Alternatives include browser-sync or gulp-livereload for more feature-rich live reloading.

npm install gulp-websocket-server
INSTALL
IMPORT
SIG · GULP-WEBSOCKET-SER
G
gulp-websocket-server
devopsjavascriptv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const gulpWss = require('gulp-websocket-server');
import gulpWss from 'gulp-websocket-server';
Package is CJS only, no default ESM export. Use require().
gulpWss
const wss = gulpWss({ port: 4000 });
const wss = new gulpWss({ port: 4000 });
gulpWss is a factory function, not a constructor. Do not use 'new'.
livereload
gulp.src('./*.js').pipe(wss.livereload('reload'));
gulp.src('./*.js').pipe(wss.livereload);
livereload() must be called with a message argument; it returns a through stream for Gulp pipe.

Shows how to create a WebSocket server in Gulp and send a 'reload' message on file changes using wss.livereload().

const gulp = require('gulp'); const gulpWss = require('gulp-websocket-server'); const wss = gulpWss({ port: 4000, path: '/ws' }); gulp.task('js', () => { return gulp.src('./src/**/*.js') .pipe(wss.livereload('reload')); }); gulp.task('default', ['js']); // Client-side: // const ws = new WebSocket('ws://localhost:4000/ws'); // ws.addEventListener('message', event => { // if (event.data === 'reload') location.reload(); // });
Debug
Known issues
deprecatedPackage is in maintenance mode; no updates since 2017. Consider using browser-sync or gulp-livereload for active development.
fix
Migrate to browser-sync or gulp-livereload.
affects: >=1.0.0
gotchaThe 'livereload' method's message argument is not optional; if omitted, no message is sent.
fix
Always provide a string argument to livereload(), e.g., .pipe(wss.livereload('reload')).
affects: >=1.0.0
gotchaThe WebSocket server path must match the client URL exactly. Default path is '/'.
fix
Set both server config { path: '/ws' } and client URL to 'ws://localhost:4000/ws'.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: gulpWss is not a constructor
Using 'new' keyword on the imported factory function.
fix
Replace 'new gulpWss(...)' with just 'gulpWss(...)'.
TypeError: wss.livereload is not a function
Calling livereload incorrectly (e.g., .pipe(wss.livereload) without parentheses).
fix
Use .pipe(wss.livereload('reload')) with parentheses and a message argument.
Module not found: Can't resolve 'ws'
Missing peer dependency 'ws'.
fix
Run 'npm install ws' to install the WebSocket library.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
wsrequiredWebSocket server implementation
Agent activity
6 hits · last 30 days
node
6
Resources
gulp-websocket-server — npm install gulp-websocket-server · libregistry