{"id":47452,"library":"easy-websocket","title":"easy-websocket","description":"A simple WebSocket server library for Node.js that provides both high-level connection handling and low-level frame manipulation. Current stable version is 0.2.1. It allows custom authentication via an optional auth callback and supports both string and binary data frames. Compared to alternatives like ws or Socket.IO, easy-websocket offers a minimal API but lacks advanced features like reconnection, automatic JSON parsing, and client-side support.","status":"maintenance","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/vincentLiuxiang/easy-websocket","tags":["javascript","websocket","easy-websocket","easywebsocket"],"install":[{"cmd":"npm install easy-websocket","lang":"bash","label":"npm"},{"cmd":"yarn add easy-websocket","lang":"bash","label":"yarn"},{"cmd":"pnpm add easy-websocket","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package does not support ESM imports; use CommonJS require.","wrong":"import websocket from 'easy-websocket';","symbol":"default (factory function)","correct":"var websocket = require('easy-websocket');"},{"note":"The low-level WebSocket protocol handler is exported via a separate path, not as a property of the main module.","wrong":"var websocketlib = require('easy-websocket').websocket;","symbol":"WebSocket protocol handler","correct":"var websocketlib = require('easy-websocket/websocket');"},{"note":"Authentication is configured by setting the auth property on the WebSocket server instance before connections.","wrong":"","symbol":"authentication override","correct":"var WebSocket = require('easy-websocket'); var ws = new WebSocket(server); ws.auth = function(req) { return false; };"}],"quickstart":{"code":"var http = require('http');\nvar fs = require('fs');\nvar websocket = require('easy-websocket');\n\nvar server = http.createServer(function(req, res) {\n  fs.readFile('./index.html', function(err, data) {\n    res.end(data);\n  });\n});\n\nwebsocket(server)\n  .on('connect', function(ws) {\n    ws.on('data', function(obj) {\n      console.log(obj.type);\n      ws.send('hello world');\n    });\n  });\n\nserver.listen(3000);","lang":"javascript","description":"Creates a simple HTTP server that serves an HTML file and upgrades connections to WebSocket using easy-websocket."},"warnings":[{"fix":"Consider using a more actively maintained WebSocket library like 'ws' or 'socket.io'.","message":"The npm package is named 'easy-websocket' but the GitHub repository does not appear to have recent updates or releases.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use require() instead of import.","message":"The main module uses CommonJS and does not support ESM imports. Attempting to import with ES modules will fail.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use require('easy-websocket/websocket') for low-level WebSocket handling.","message":"The documentation example shows 'require('easy-websocket/ws')' which is not a valid path. The correct low-level path is 'easy-websocket/websocket'.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use @types/easy-websocket if available, or define your own types.","message":"The package does not include TypeScript type definitions.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.2.1':29 'advanc':63 'allow':31 'altern':49 'api':60 'auth':37 'authent':33 'automat':67 'binari':44 'callback':38 'client':72 'client-sid':71 'compar':47 'connect':17 'current':25 'custom':32 'data':45 'easi':2,55,78 'easy-websocket':1,54,77 'easywebsocket':80 'featur':64 'frame':23,46 'handl':18 'high':15 'high-level':14 'javascript':75 'json':68 'lack':62 'level':16,22 'librari':8 'like':50,65 'low':21 'low-level':20 'manipul':24 'minim':59 'node.js':10 'offer':57 'option':36 'pars':69 'provid':12 'reconnect':66 'server':7 'side':73 'simpl':5 'socket.io':53 'stabl':26 'string':42 'support':40,74 'version':27 'via':34 'websocket':3,6,56,76,79 'ws':51","created_at":"2026-06-07T16:51:35.446607+00:00","updated_at":"2026-06-07T16:51:35.446607+00:00","problems":[{"fix":"Change to require('easy-websocket/websocket')","cause":"Incorrect path for low-level WebSocket protocol handler; the documentation lists 'ws' but the correct path is 'websocket'.","error":"Error: Cannot find module 'easy-websocket/ws'"},{"fix":"Use const websocket = require('easy-websocket');","cause":"Attempting to use ES module import syntax with a CommonJS package.","error":"TypeError: websocket is not a function"},{"fix":"In browser code, use the native WebSocket API directly. For server code, ensure you are using Node.js and the correct require path.","cause":"This library is intended for server-side Node.js, not browser environments. The `WebSocket` global in the example is the browser's native WebSocket.","error":"ReferenceError: WebSocket is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/vincentLiuxiang/easy-websocket#readme","github":"https://github.com/vincentLiuxiang/easy-websocket","docs":null,"changelog":null,"pypi":null,"npm":"easy-websocket","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}