{"record":{"id":"b5e1f9a68e1cd3f6","repo":"vuejs/vue-router","slug":"non-nested-routes-must-include-a-leading-slash-cha","errorCode":null,"errorMessage":"Non-nested routes must include a leading slash character. Fix the following routes: \n${pathNames}","messagePattern":"Non-nested routes must include a leading slash character\\. Fix the following routes: \n(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/create-route-map.js","lineNumber":46,"sourceCode":"\n  // ensure wildcard routes are always at the end\n  for (let i = 0, l = pathList.length; i < l; i++) {\n    if (pathList[i] === '*') {\n      pathList.push(pathList.splice(i, 1)[0])\n      l--\n      i--\n    }\n  }\n\n  if (process.env.NODE_ENV === 'development') {\n    // warn if routes do not include leading slashes\n    const found = pathList\n    // check for missing leading slash\n      .filter(path => path && path.charAt(0) !== '*' && path.charAt(0) !== '/')\n\n    if (found.length > 0) {\n      const pathNames = found.map(path => `- ${path}`).join('\\n')\n      warn(false, `Non-nested routes must include a leading slash character. Fix the following routes: \\n${pathNames}`)\n    }\n  }\n\n  return {\n    pathList,\n    pathMap,\n    nameMap\n  }\n}\n\nfunction addRouteRecord (\n  pathList: Array<string>,\n  pathMap: Dictionary<RouteRecord>,\n  nameMap: Dictionary<RouteRecord>,\n  route: RouteConfig,\n  parent?: RouteRecord,\n  matchAs?: string\n) {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/vuejs/vue-router/blob/680ccc68c506cca9be6207745043245d61fa715a/src/create-route-map.js#L28-L64","documentation":"vue-router requires top-level (non-nested) route paths to start with '/'. During route-map creation, any path in the top-level pathList that neither starts with '/' nor '*' is collected and reported so the routes simply won't match as expected.","triggerScenarios":"Declaring a root route without a leading slash, e.g. routes: [{ path: 'home', component: Home }] passed directly to new Router({ routes }) — only child paths may omit the slash.","commonSituations":"Copying a child route config to the top level; building routes from data where the slash was stripped; nested route arrays accidentally flattened.","solutions":["Add a leading '/' to every top-level route path: 'home' -> '/home'","Use '*' (wildcard) only intentionally, it is exempt","Validate route configs before passing them to the router","Move the route under a parent as children if relative paths are intended"],"exampleFix":"// before\nroutes: [{ path: 'home', component: Home }]\n// after\nroutes: [{ path: '/home', component: Home }]","handlingStrategy":"validation","validationCode":"routes.forEach(r => {\n  if (typeof r.path === 'string' && r.path && r.path[0] !== '*' && r.path[0] !== '/') {\n    throw new Error(`Top-level route path must start with '/': ${r.path}`)\n  }\n})","typeGuard":"function hasLeadingSlash(p) { return typeof p === 'string' && (p[0] === '/' || p[0] === '*') }","tryCatchPattern":null,"preventionTips":["Top-level paths always start with '/'; only child paths may be relative","Normalize paths in route-config loaders before registering","Keep child routes nested rather than flattening arrays"],"tags":["vue-router","routing","path","configuration"],"backgroundTag":"route-path-missing-leading-slash","analyzedSha":"680ccc68c506cca9be6207745043245d61fa715a","analyzedAt":"2026-09-02T19:19:01.204Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}