Registry / web-framework / my-server

my-server

JSON →
library0.8.5jsnpmunverified

My Server (npm package `my-server`) is a minimalist, zero-dependency HTTP server for Node.js. It allows developers to quickly set up a simple web server to serve files or respond to HTTP requests with custom handlers. Currently stable at version 2.0.7, the package was last published in January 2020, suggesting a low-cadence or maintenance mode of development, with no significant updates since. Its primary differentiator is its extreme simplicity and lack of external dependencies, making it suitable for lightweight use cases like local development, prototyping, or basic API mocking, without the overhead of larger frameworks.

npm install my-server
INSTALL
IMPORT
SIG · MY-SERVER
M
my-server
web-frameworkjavascriptv0.8.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

server
const server = require('my-server')();
const myServer = require('my-server'); // or import { server } from 'my-server';
The `my-server` package exports a function which must be immediately invoked to get the server instance. This is a CommonJS module and may not work directly with ESM `import` statements without Node.js interoperability features.
server.listen
server.listen(5000);
require('my-server').listen(5000);
The `listen` method is available on the server instance returned by the package's invoked function, not directly on the `require`'d function itself.

Demonstrates setting up a basic `my-server` instance, registering a universal handler for all routes, and starting the HTTP server on a specified port, outputting request details as JSON.

const server = require('my-server')(); // Register a universal handler for all incoming requests server.all(function (req, res) { // Log details of the incoming request console.log(`Received ${req.method} request for ${req.url}`); // Respond with a JSON object containing request details res.json({ headers: req.headers, method: req.method, range: req.headers.range, url: req.url }, 0, 2); // The 0 and 2 are indentation arguments for JSON.stringify }); // Start the server on port 5000 const port = process.env.PORT ?? 5000; server.listen(port, () => { console.log(`My Server is running on http://localhost:${port}`); console.log('Access http://localhost:5000/some/path to see response.'); });
my-server --version
Debug
Known issues
gotchaThe `my-server` package is a CommonJS module (CJS) and does not natively support ES Modules (ESM) `import` syntax. Attempting to `import` it in a pure ESM context (e.g., in a Node.js project with `"type": "module"` set in `package.json`) will likely result in an error or require manual interoperability configuration.
fix
Use CommonJS `require()` syntax: `const server = require('my-server')();`. If strictly in an ESM context, consider dynamic `import()` or using a CJS wrapper.
affects: >=1.0.0
deprecatedThe `my-server` package has not been updated since January 2020. While a simple file server may not require frequent updates, this indicates a lack of active maintenance, which could lead to compatibility issues with newer Node.js versions or unaddressed security vulnerabilities for production use cases.
fix
For critical applications, evaluate the source code for known vulnerabilities or consider more actively maintained HTTP server libraries. For simple development, its stability might be sufficient, but monitor Node.js compatibility.
affects: >=2.0.7
gotchaThe package exports a function that must be *invoked* (`()`) immediately after `require()` to obtain the server instance. Forgetting to call this function will lead to a `TypeError` when attempting to call methods like `listen` or `all` on the raw function.
fix
Always initialize the server instance by calling the imported function: `const server = require('my-server')();`.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: server.listen is not a function
The imported `my-server` function was not invoked, so `server` is still a function, not the server instance.
fix
Ensure the `my-server` function is called: `const server = require('my-server')();`
Error: listen EADDRINUSE: address already in use :::5000
Another process is already using the specified port (e.g., port 5000).
fix
Change the port number passed to `server.listen(PORT)` or terminate the process currently using the port.
ReferenceError: require is not defined in ES module scope
Attempting to use `require()` in an ES Module (`.mjs` file or `"type": "module"` in `package.json`) context.
fix
The `my-server` package is CJS-only. To use it in an ESM project, consider a dynamic import (`import('my-server').then(mod => mod() )`) or stick to CommonJS for this part of your application. For new projects, prefer modern ESM-compatible server frameworks.
Upgrade
Version history
0.8.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
my-server — npm install my-server · libregistry