{"id":16016,"library":"electrode-server","title":"Electrode Hapi Web Server","description":"Electrode Server is a configurable web server built atop Hapi.js and Node.js, designed to standardize the setup and serving of web applications. The current stable version is 3.3.0. It provides a baseline Hapi server instance that can be extended primarily through configuration, reducing the need for boilerplate code and duplicated server setup logic across projects. While offering default settings that allow for a quick startup, its strength lies in its extensive configuration options, managed optionally by tools like `electrode-confippet`, enabling fine-grained control over Hapi server and connection settings, including port, host, compression, and plugin registration. It simplifies the integration of Hapi plugins by providing a structured way to register them. Electrode Server aims to abstract away common server setup concerns, allowing developers to focus on application-specific features and logic. The package does not explicitly detail its release cadence, but minor versions are released as needed.","status":"active","version":"3.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/electrode-io/electrode-server","tags":["javascript","electrode","hapi","node","webserver"],"install":[{"cmd":"npm install electrode-server","lang":"bash","label":"npm"},{"cmd":"yarn add electrode-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add electrode-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Recommended for managing complex application configurations, though not strictly required for basic use.","package":"electrode-confippet","optional":true}],"imports":[{"note":"The primary API is a function exported directly by the module. This package is CommonJS-only.","wrong":"import startServer from 'electrode-server';","symbol":"ElectrodeServerFunction","correct":"const startServer = require('electrode-server');"},{"note":"The module can be invoked directly upon require to start a server with default settings. Using ESM import statements will fail.","wrong":"import 'electrode-server';","symbol":"DirectServerStart","correct":"require('electrode-server')();"},{"note":"Configuration is passed as an argument to the function returned by `require('electrode-server')`. ESM named imports are not supported.","wrong":"import electrodeServer from 'electrode-server'; electrodeServer({ connection: { port: 9000 } });","symbol":"ConfiguredServerStart","correct":"const config = { connection: { port: 9000 } }; require('electrode-server')(config);"}],"quickstart":{"code":"const config = {\n  connection: {\n    host: process.env.HOST ?? 'localhost',\n    port: parseInt(process.env.PORT ?? '3000', 10),\n    routes: {\n      cors: true\n    }\n  },\n  plugins: {\n    'my-routes-plugin': {\n      register: (server, options) => {\n        server.route({\n          method: 'GET',\n          path: '/',\n          handler: (request, h) => {\n            return 'Hello, Electrode Server!';\n          }\n        });\n      },\n      options: {}\n    }\n  }\n};\n\nrequire('electrode-server')(config);\n\nconsole.log(`Electrode Server running on http://${config.connection.host}:${config.connection.port}`);","lang":"javascript","description":"Demonstrates starting an Electrode server on a custom port with a basic Hapi route registered via the plugin configuration."},"warnings":[{"fix":"Ensure your project's Node.js environment is version 8 or higher. Update your `package.json` engines field accordingly.","message":"The minimum Node.js version required has been updated from `>= 4.2.2` to `v8.x.x+` (as stated in the README). Running on older Node.js environments will lead to errors.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Refactor your server configuration to use the `connection` object for a single server definition, instead of the deprecated `connections` object.","message":"The `connections` configuration object, which previously allowed defining multiple connections, has been deprecated. Only a single connection object (`connection`) is now supported, implying a single server instance. Migrating from older versions requires adjusting your server configuration.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Always use the CommonJS `require()` syntax to import and interact with `electrode-server`.","message":"This package is implemented as a CommonJS module. Attempting to use ES Modules `import` syntax will result in `ERR_REQUIRE_ESM` or similar errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Register your Hapi plugins containing route definitions through the `plugins` configuration object when initializing `electrode-server`.","message":"When running the server with default settings, accessing `http://localhost:3000` will return a `404 Not Found` response because no routes are registered by default. You must configure Hapi plugins to add routes and handlers.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Run `npm install electrode-server` or `yarn add electrode-server` in your project directory.","cause":"The package `electrode-server` has not been installed.","error":"Error: Cannot find module 'electrode-server'"},{"fix":"Ensure you are using Node.js v8.x.x+ as required by the module. Verify `electrode-server` is installed correctly.","cause":"Attempting to call `require('electrode-server')` as a function, but the module might not be correctly exported or Node.js versions mismatch.","error":"TypeError: require(...) is not a function"},{"fix":"Verify that your Hapi plugin module correctly exports a `register` function and that the `module` or `register` property in your `electrode-server` plugin configuration points to the correct location/function.","cause":"A Hapi plugin defined in the `plugins` configuration is missing the required `register` function, or the module path is incorrect.","error":"Error: plugin 'your-plugin-name' missing a 'register' property"}],"ecosystem":"npm"}