{"record":{"id":"ce1bea87b109e493","repo":"remix-run/remix","slug":"rmx-route-map-loader-invalid-json","errorCode":"RMX_ROUTE_MAP_LOADER_INVALID_JSON","errorMessage":"Route-map loader returned invalid JSON","messagePattern":"Route-map loader returned invalid JSON","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/lib/errors.ts","lineNumber":113,"sourceCode":"    title: 'Could not find a project root',\n    fix: 'Run this command inside a Remix project.',\n  },\n  remixConfigNotFound: {\n    code: 'RMX_CONFIG_NOT_FOUND',\n    title: 'Remix configuration not found',\n    fix: 'Check the --config path and try again.',\n  },\n  remoteSkillDataMissing: {\n    code: 'RMX_REMOTE_SKILL_DATA_MISSING',\n    title: 'Could not find remote Remix skill data',\n  },\n  routeMapLoaderFailed: {\n    code: 'RMX_ROUTE_MAP_LOADER_FAILED',\n    title: 'Route-map loader failed',\n    fix: 'Check app/routes.ts and make sure it exports a named `routes` value with a valid route map.',\n  },\n  routeMapLoaderInvalidJson: {\n    code: 'RMX_ROUTE_MAP_LOADER_INVALID_JSON',\n    title: 'Route-map loader returned invalid JSON',\n    fix: 'Check app/routes.ts and make sure route-map loading does not write extra output.',\n  },\n  routeMapLoaderSignal: {\n    code: 'RMX_ROUTE_MAP_LOADER_SIGNAL',\n    title: 'Route-map loader exited from a signal',\n    fix: 'Check app/routes.ts for side effects or runtime issues and try again.',\n  },\n  routeOwnerPlanUnresolved: {\n    code: 'RMX_ROUTE_OWNER_PLAN_UNRESOLVED',\n    title: 'Could not resolve a route owner plan',\n  },\n  routesFileNotFound: {\n    code: 'RMX_ROUTES_FILE_NOT_FOUND',\n    title: 'Could not find app/routes.ts',\n    fix: 'Run this command inside a Remix app that has app/routes.ts.',\n  },\n  targetDirectoryNotEmpty: {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/cli/src/lib/errors.ts#L95-L131","documentation":"The route-map loader subprocess ran successfully but printed content that is not valid JSON on the channel the CLI parses. Anything app/routes.ts (or its imports) writes to stdout during loading corrupts the JSON handshake. The CLI therefore cannot extract the route map.","triggerScenarios":"app/routes.ts or one of its imports calling console.log/process.stdout.write at module scope; a dependency printing a banner; output buffering interleaving with the loader's JSON payload.","commonSituations":"Debug console.log statements left in route config files, noisy third-party imports (analytics SDKs, debug libraries), or polyfills that print during import.","solutions":["Remove console.log/process.stdout.write calls from app/routes.ts and any modules it imports at load time.","Move logging into route handlers or lazy-loaded modules instead of module scope.","If you need debug output while authoring routes, write to stderr or a file instead of stdout.","Re-run the CLI command to confirm the JSON parses."],"exampleFix":"// before\n// app/routes.ts\nconsole.log('building routes', config)\nexport const routes = config\n\n// after\n// app/routes.ts\nexport const routes = [\n  { path: '/', file: 'routes/index.tsx' },\n]","handlingStrategy":"validation","validationCode":"// Before loading, ensure route modules don't write to stdout\nlet src = await readFile('app/routes.ts', 'utf8')\nif (/console\\.log|process\\.stdout\\.write/.test(src)) {\n  throw new Error('route config writes to stdout')\n}","typeGuard":null,"tryCatchPattern":"try {\n  let map = await loadRouteMap()\n} catch (error) {\n  if (error.code === 'RMX_ROUTE_MAP_LOADER_INVALID_JSON') {\n    // strip stdout writes from route config imports\n  }\n}","preventionTips":["Never console.log at module scope in app/routes.ts.","Log from route config to stderr only."],"tags":["cli","routes","json"],"backgroundTag":"stdout-corrupted-json-output","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}