vuejs/vue-router · warning
Duplicate param keys in route with path: "${path}"
Error message
Duplicate param keys in route with path: "${path}" What it means
A route path declares the same param name more than once (e.g. '/:id/:id'), producing duplicate keys in the compiled regex. The param value would be overwritten ambiguously, so vue-router warns during path-to-regexp compilation in dev.
Source
Thrown at src/create-route-map.js:201
} else if (process.env.NODE_ENV !== 'production' && !matchAs) {
warn(
false,
`Duplicate named routes definition: ` +
`{ name: "${name}", path: "${record.path}" }`
)
}
}
}
function compileRouteRegex (
path: string,
pathToRegexpOptions: PathToRegexpOptions
): RouteRegExp {
const regex = Regexp(path, [], pathToRegexpOptions)
if (process.env.NODE_ENV !== 'production') {
const keys: any = Object.create(null)
regex.keys.forEach(key => {
warn(
!keys[key.name],
`Duplicate param keys in route with path: "${path}"`
)
keys[key.name] = true
})
}
return regex
}
function normalizePath (
path: string,
parent?: RouteRecord,
strict?: boolean
): string {
if (!strict) path = path.replace(/\/$/, '')
if (path[0] === '/') return path
if (parent == null) return path
return cleanPath(`${parent.path}/${path}`)View on GitHub (pinned to 680ccc68c5)
Solutions
- Give each param a unique name: '/user/:userId/posts/:postId'
- Inspect the generated path string if paths are built dynamically
- Refactor so the same value is not captured twice (use one segment or a query param)
- Test path matching after renaming params to update this.$route.params consumers
Example fix
// before
{ path: '/user/:id/posts/:id' }
// after
{ path: '/user/:userId/posts/:postId' } Defensive patterns
Strategy: validation
Validate before calling
function assertUniqueParams(path) {
const names = (path.match(/:[^/?]+/g) || []).map(s => s.replace(/[^\w]/g, ''))
const dupes = names.filter((n, i) => names.indexOf(n) !== i)
if (dupes.length) throw new Error(`Duplicate params ${dupes} in path: ${path}`)
} Prevention
- Never repeat the same :param name within one path
- When building paths from templates, verify interpolated param names differ
- Rename this.$route.params consumers after deduplicating params
When it happens
Trigger: Paths like '/:id/:id', '/user/:id/posts/:id', or repeated optional params '/:a?/:a?' where key.name collides in regex.keys.
Common situations: Copy-paste of path segments; template-string path builders that interpolate the same param twice; renaming params in one place but not another.
Related errors
- props in "${route.path}" is a ${typeof config}, expecting an
- invalid redirect option: ${JSON.stringify(redirect)}
- Non-nested routes must include a leading slash character. Fi
- Route with path "${path}" contains unencoded characters, mak
- Named Route '${route.name}' has a default child route. When
AI-assisted analysis of vuejs/vue-router@680ccc68c5 (2026-09-02).
Data as JSON: /api/errors/732a1ebc8881141d.
Report an issue: GitHub.