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.
default (plugin)
✓ exports.gymboAuth = {
enable: true,
package: 'egg-gymbo-auth',
};
✗ exports.gymboAuth = {
enable: true,
package: 'egg-gymboree-auth',
};
The package name is 'egg-gymbo-auth', not 'egg-gymboree-auth'. The plugin is configured in config/plugin.js as shown.
middleware
✓ app.middleware.gymboAuth(ctx, next);
✗ const gymboAuth = require('egg-gymbo-auth');
The middleware is not a direct import; it is accessible via app.middleware after enabling the plugin.
config
✓ // config/config.default.js
exports.gymboAuth = {
secret: 'your-secret',
};
✗ const config = require('egg-gymbo-auth');
Configuration is done via Egg's config object, not by importing the package directly.
Shows how to enable the plugin, configure it, and apply the middleware to a route.
// config/plugin.js
exports.gymboAuth = {
enable: true,
package: 'egg-gymbo-auth',
};
// config/config.default.js
exports.gymboAuth = {
secret: process.env.AUTH_SECRET || 'default-secret',
ignore: ['/login', '/register'],
};
// app/router.js
module.exports = app => {
const { router, controller, middleware } = app;
router.get('/protected', middleware.gymboAuth(), controller.home.protected);
router.get('/login', controller.home.login);
};
// app/controller/home.js
exports.protected = async ctx => {
ctx.body = { message: 'Authenticated', user: ctx.state.user };
};
exports.login = async ctx => {
// dummy login
ctx.body = { token: 'fake-token' };
};
Errors
Common errors & fixes
Error: Cannot find module 'egg-gymbo-auth'
Package not installed or name misspelled.
fixRun 'npm install egg-gymbo-auth' and check spelling in plugin.js.
TypeError: app.middleware.gymboAuth is not a function
Plugin not enabled or middleware not registered correctly.
fixEnsure plugin is enabled in config/plugin.js and that the plugin has been loaded (check if it requires Egg 1.x).
Audit
Dependencies
No dependency data recorded yet.