decolua/9router · critical · Error
MITM server.js not found at ${effectiveServerPath}. Reinstal
Error message
MITM server.js not found at ${effectiveServerPath}. Reinstall 9router. What it means
Before spawning the MITM worker, startServer verifies SERVER_PATH (the runtime-copied mitm server.js) exists. If missing, it re-copies the bundled copy via ensureRuntimeServer(resolveBundledServerPath()) and re-checks; if the recopy also yields nothing it throws 'MITM server.js not found at <path>. Reinstall 9router.' This means the runtime asset could not be located or restored from the installed package.
Source
Thrown at src/mitm/manager.js:581
try {
await installCert(password, rootCACertPath);
log("🔐 Cert: ✅ trusted");
} catch (e) {
throw new Error(`Failed to trust certificate: ${e.message}`);
}
}
} else {
log("🔐 Cert: already trusted ✅");
}
// Step 2: Spawn server (Root CA already installed in Step 1.5)
// Verify server.js exists — recopy if runtime file was deleted (antivirus/cleanup)
let effectiveServerPath = SERVER_PATH;
if (!effectiveServerPath || !fs.existsSync(effectiveServerPath)) {
log(`[MITM] server.js missing at ${effectiveServerPath} → recopying`);
effectiveServerPath = ensureRuntimeServer(resolveBundledServerPath());
if (!effectiveServerPath || !fs.existsSync(effectiveServerPath)) {
throw new Error(`MITM server.js not found at ${effectiveServerPath}. Reinstall 9router.`);
}
}
const mitmRouterBase = await resolveMitmRouterBaseUrl();
log(`🚀 Starting server... (router: ${mitmRouterBase})`);
if (IS_WIN) {
// Check port 443 — ask user before killing
const winOwner = await getPort443Owner(sudoPassword);
if (winOwner) {
if (forceKillPort443) {
log(`Killing process on port 443 (PID ${winOwner.pid}, name=${winOwner.name})...`);
await killPort443Owner(winOwner, sudoPassword);
} else {
const e = new Error(`Port 443 is already in use by "${winOwner.name}" (PID ${winOwner.pid}).`);
e.code = "PORT_443_BUSY";
e.portOwner = { pid: winOwner.pid, name: winOwner.name };
throw e;
}
}View on GitHub (pinned to 90b52e06ff)
Solutions
- Reinstall the package: `npm install -g 9router` (or re-run the CLI installer) so the bundled server asset is restored
- Check whether AV quarantined the file and whitelist ~/.9router (and the package install dir) before reinstalling
- Verify the runtime dir contents — delete the MITM runtime folder under ~/.9router so the next start recopies everything fresh from the bundle
- If developing locally, run the build/bundle step that emits the MITM server asset and confirm resolveBundledServerPath() points at an existing file
Example fix
// after reinstalling, force a clean recopy rm -rf ~/.9router/mitm && npx 9router start // or in code, verify before starting if (!fs.existsSync(serverPath)) await reinstall9router(); // before startServer(apiKey)
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
const path = require('path');
function assertMitmRuntimePresent() {
const mitmDir = require('os').homedir() + '/.9router/mitm';
const serverPath = path.join(mitmDir, 'server.js');
if (!fs.existsSync(serverPath)) {
throw new Error(`MITM runtime missing at ${serverPath} — reinstall 9router before starting the proxy.`);
}
return serverPath;
} Try / catch
try {
await startServer(apiKey);
} catch (e) {
if (/MITM server\.js not found/.test(e.message)) {
console.error('Runtime files missing — reinstalling 9router is required:', e.message);
// do NOT retry; surface an actionable reinstall step to the user
} else throw e;
} Prevention
- Whitelist ~/.9router and the global npm install dir in antivirus/EDR software
- After any version upgrade, verify the runtime server.js exists before starting
- Reinstall via npm rather than copying files by hand so bundled assets land correctly
- In CI/Docker, bake the runtime copy into the image instead of relying on first-start recopy
When it happens
Trigger: SERVER_PATH unset or the runtime file deleted (antivirus quarantine, disk cleanup) AND resolveBundledServerPath() returns null/empty or a non-existent path — e.g. running from a source checkout without the bundled asset, a broken/partial npm install, or a package layout change where the bundled server.js isn't where expected.
Common situations: Windows Defender or corporate AV quarantining mitm server.js repeatedly (this is exactly the recopy path's reason for existing); installing via a truncated npm cache or partial download; running cli/ from a dev clone where the bundling step that places the asset wasn't run; upgrading versions with a stale half-deleted runtime directory under ~/.9router.
Related errors
- Installation finished but tailscale.exe not found
- Certificate file not found: ${certPath}
- MITM server is already starting (lock contention)
- Root CA not found. Start server first to generate it.
- Machine ID is required for Cursor API
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/0249ea9e235fd6df.
Report an issue: GitHub.