Changelog - 2026-09-06
configs.projectRoot
New FeatureIn one line. The project root is a config value; the override that every application copied to return __dirname becomes one line.
What changed
IServerApplicationConfigs.projectRootis a new optional string.ServerApplication.getProjectRoot()returnsconfigs.projectRoot ?? process.cwd()and still bindsCoreBindings.APPLICATION_PROJECT_ROOT.- The root now decides where optional peers are looked up.
ModuleUtility.loadSyncandassertInstalled(mail transports, secrets providers) and the gRPC adapter resolve under<projectRoot>/node_modulesinstead of the process cwd. New:ModuleUtility.setProjectRoot()andgetProjectRoot(). The pino transports resolve at the first log line, usually before an application exists, and keep using the cwd. - Set it only to the directory that holds
node_modulesat run time. In abun build --compilebinary,__dirnameis the compile-time directory andimport.meta.diris virtual, so leave the option unset (the cwd) or derive it fromprocess.execPath. If the option is set and<projectRoot>/node_modulesdoes not exist, the boot log carries one warning. - The value is read in the base constructor, before
preConfigure(), so it must come from the config object, not from something bound later. - An override of
getProjectRoot()still wins.
typescript
export const configs: IServerApplicationConfigs = {
path: { base: '/api', isStrict: true },
projectRoot: process.env.APP_ROOT ?? process.cwd(),
};Who is affected
- Applications that override
getProjectRoot()only to return__dirname. Delete the override; the default (process.cwd()) is what peer resolution used all along. SetprojectRootonly when the process really runs from another directory, and never to__dirnamein a compiled binary. - Everyone else. No action needed.
Details
- Reference: Application.