Egg Core Framework

5.5.1 · deprecated · verified Sun Apr 19

egg-core, at version 5.5.1, is the foundational module of the Egg.js framework, a highly extensible web framework for Node.js built upon Koa. It provides the core loading mechanisms, plugin system, and application context management essential for enterprise-grade web applications. While the unscoped `egg-core` package saw its last update to 5.5.1 in January 2025, active development has since transitioned to its successor, `@eggjs/core`. The `@eggjs/core` package, with `v6.5.0` as its current stable release, continues to evolve the framework with features like enhanced TypeScript support, Vitest integration, and refined lifecycle management. Both `egg-core` and `@eggjs/core` adhere to a convention-over-configuration philosophy, offering a powerful plugin system and environment-aware configurations for extensible and maintainable server-side applications. This package is typically consumed as a dependency by the main `egg` framework, rather than being directly integrated into end-user applications.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate and start a minimal EggCore application, including listening for HTTP requests.

import { EggCore } from 'egg-core';
import { join } from 'path';

async function startApp() {
  const app = new EggCore({
    baseDir: join(__dirname, 'my-egg-app'),
    // Other options like 'env', 'plugins'
  });

  // Application ready event, often used to start listening for requests
  app.ready(() => {
    console.log(`Egg application is ready.`);
    app.listen(3000, () => {
      console.log('Server listening on http://localhost:3000');
    });
  });

  // You might also need to initialize the app loader, typically done internally by the framework
  // For advanced usage, direct loader API can be used:
  // const loader = new EggLoader({ baseDir: app.baseDir, app });
  // loader.loadConfig();
  // loader.loadController();
  // ...
}

startApp().catch(err => {
  console.error('Application startup failed:', err);
  process.exit(1);
});

view raw JSON →