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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
GithubWebHook
✓ const GithubWebHook = require('express-github-webhook');
✗ import { GithubWebHook } from 'express-github-webhook';
This package is CJS-only; no ESM support.
webhookHandler
✓ const webhookHandler = GithubWebHook({ secret: 'mysecret' });
✗ const webhookHandler = new GithubWebHook();
GithubWebHook is a factory function, not a constructor. Do not use 'new'.
on
✓ webhookHandler.on('push', function(repo, data) { ... });
✗ webhookHandler.on('push', function(event, repo, data) { ... });
For named events (not '*'), callback signature is (repo, data). The 'event' parameter is omitted.
Sets up an Express server with body-parser and the GitHub webhook middleware, listens for push events and wildcard events.
const express = require('express');
const bodyParser = require('body-parser');
const GithubWebHook = require('express-github-webhook');
const app = express();
app.use(bodyParser.json());
const webhookHandler = GithubWebHook({ path: '/webhook', secret: process.env.GITHUB_SECRET ?? '' });
app.use(webhookHandler);
webhookHandler.on('push', function(repo, data) {
console.log('Push event on repo:', repo);
console.log('Payload:', data);
});
webhookHandler.on('*', function(event, repo, data) {
console.log(`Any event ${event} on repo ${repo}`);
});
app.listen(3000, () => console.log('Server listening on port 3000'));
Errors
Common errors & fixes
TypeError: GithubWebHook is not a constructor
Using 'new' keyword on the factory function.
fixRemove 'new': const webhookHandler = GithubWebHook({ secret: '...' }); Error: secret is required to verify signature
Request has a signature but no secret was provided in options.
fixProvide a secret matching the GitHub webhook secret, or disable signature verification by not setting a secret (not recommended).
Cannot find module 'body-parser'
body-parser not installed.
fixRun 'npm install body-parser' and ensure it is required before the middleware.
webhookHandler.on('push', function(event, repo, data) {...}) but event is undefined
Using incorrect callback signature for specific events.
fixUse function(repo, data) for specific events, or function(event, repo, data) for '*' only.
SyntaxError: Unexpected token u in JSON at position 0
body-parser not applied before the middleware, leaving req.body as undefined.
fixAdd app.use(bodyParser.json()) before app.use(webhookHandler).
Audit
Dependencies
body-parserrequiredRequired to parse JSON request bodies before the middleware runs