vercel/next.js · error
Specified images.localPatterns should be an Array received $
Error message
Specified images.localPatterns should be an Array received ${typeof images.localPatterns}.
See more info here: https://nextjs.org/docs/messages/invalid-images-config What it means
`images.localPatterns` controls which local URLs the image optimizer will fetch. It must be an array of `{ pathname, search }` glob-pattern objects. The guard at config.ts:653-658 rejects any truthy non-array value because the next step calls `.some()` / `.push()` on it. If left unset, Next.js seeds a default allowing all local paths.
Source
Thrown at packages/next/src/server/config.ts:655
if (result.assetPrefix === '') {
result.assetPrefix = result.basePath
}
}
}
if (result?.images) {
const images: ImageConfig = result.images
if (typeof images !== 'object') {
throw new Error(
`Specified images should be an object received ${typeof images}.\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config`
)
}
if (images.localPatterns) {
if (!Array.isArray(images.localPatterns)) {
throw new Error(
`Specified images.localPatterns should be an Array received ${typeof images.localPatterns}.\nSee more info here: https://nextjs.org/docs/messages/invalid-images-config`
)
}
// avoid double-pushing the same pattern if it already exists
if (
!images.localPatterns.some(
(pattern) =>
pattern.pathname === '/_next/static/media/**' &&
pattern.search === ''
)
) {
// static import images are automatically allowed
images.localPatterns.push({
pathname: '/_next/static/media/**',
search: '',
})
}
if (View on GitHub (pinned to 0ae8c72462)
Solutions
- Wrap your pattern in an array: `localPatterns: [{ pathname: '/assets/**', search: '' }]`.
- Confirm each entry has `pathname` (string glob) and optional `search` (string).
- If you want all local paths, omit localPatterns entirely so Next.js applies the default.
Example fix
// before
module.exports = { images: { localPatterns: { pathname: '/assets/**' } } }
// after
module.exports = { images: { localPatterns: [{ pathname: '/assets/**', search: '' }] } } Defensive patterns
Strategy: type-guard
Validate before calling
const lp = config.images?.localPatterns;
if (lp != null && !Array.isArray(lp)) throw new Error('images.localPatterns must be an array');
for (const p of lp ?? []) { if (typeof p.pathname !== 'string') throw new Error('each localPattern needs a pathname string'); } Type guard
type LocalPattern = { pathname: string; search?: string };
function isLocalPatternsArray(v: unknown): v is LocalPattern[] {
return Array.isArray(v) && v.every((p) => p && typeof (p as any).pathname === 'string');
} Prevention
- Always wrap individual patterns in an array literal in config.
- Lint config files for `localPatterns:` followed by `{` instead of `[`.
When it happens
Trigger: Setting `images: { localPatterns: { pathname: '/assets/**' } }` (an object instead of an array), or `localPatterns: '/assets/**'` (a string).
Common situations: Migrating from `remotePatterns`/`domains` and assuming localPatterns takes a single object. Misreading docs and supplying one pattern object rather than an array of one.
Related errors
- Specified images should be an object received ${typeof image
- Specified images.remotePatterns should be an Array received
- Specified images.remotePatterns must have protocol "http" or
- Invalid assetPrefix provided. Original error: ${error}
- Specified images.domains should be an Array received ${typeo
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/cbccc8b642af7573.
Report an issue: GitHub.