{"record":{"id":"6b25247fcde400d2","repo":"vercel/next.js","slug":"specified-images-loader-property-images-loader-6b2524","errorCode":null,"errorMessage":"Specified images.loader property (${images.loader}) cannot be used with images.loaderFile property. Please set images.loader to \"custom\".","messagePattern":"Specified images\\.loader property \\((.+?)\\) cannot be used with images\\.loaderFile property\\. Please set images\\.loader to \"custom\"\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/config.ts","lineNumber":791,"sourceCode":"      images.path === imageConfigDefault.path &&\n      result.basePath &&\n      !pathHasPrefix(images.path, result.basePath)\n    ) {\n      images.path = `${result.basePath}${images.path}`\n    }\n\n    // Append trailing slash for non-default loaders and when trailingSlash is set\n    if (\n      images.path &&\n      !images.path.endsWith('/') &&\n      (images.loader !== 'default' || result.trailingSlash)\n    ) {\n      images.path += '/'\n    }\n\n    if (images.loaderFile) {\n      if (images.loader !== 'default' && images.loader !== 'custom') {\n        throw new Error(\n          `Specified images.loader property (${images.loader}) cannot be used with images.loaderFile property. Please set images.loader to \"custom\".`\n        )\n      }\n      const absolutePath = join(dir, images.loaderFile)\n      if (!existsSync(absolutePath)) {\n        throw new Error(\n          `Specified images.loaderFile does not exist at \"${absolutePath}\".`\n        )\n      }\n      images.loaderFile = absolutePath\n    }\n  }\n\n  warnCustomizedOption(\n    result,\n    'experimental.esmExternals',\n    true,\n    'experimental.esmExternals is not recommended to be modified as it may disrupt module resolution',","sourceCodeStart":773,"sourceCodeEnd":809,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/config.ts#L773-L809","documentation":"`images.loaderFile` is only valid with `loader: 'default'` (where the file overrides the default) or `loader: 'custom'` (fully custom loader). The check at config.ts:789-794 throws when loaderFile is set but loader is a built-in named loader like 'cloudinary', because mixing a built-in loader with a custom file is contradictory and the framework cannot decide which to use.","triggerScenarios":"Setting both `images: { loader: 'cloudinary', loaderFile: './my-loader.js' }`. The named loader would override the file, so the combination is rejected.","commonSituations":"Starting from a named loader config and adding a loaderFile to tweak behavior, instead of switching loader to 'custom'. Copying loaderFile from an example while leaving a previous loader value.","solutions":["Set `loader: 'custom'` when supplying `loaderFile`: `images: { loader: 'custom', loaderFile: './loaders/my-loader.ts' }`.","Or remove `loaderFile` if you want to keep the built-in named loader.","Confirm the loaderFile exports a default function with the `({ src, width, quality }) => string` signature."],"exampleFix":"// before\nmodule.exports = { images: { loader: 'cloudinary', loaderFile: './my-loader.js' } }\n// after\nmodule.exports = { images: { loader: 'custom', loaderFile: './my-loader.js' } }","handlingStrategy":"validation","validationCode":"const { loader, loaderFile } = config.images ?? {};\nif (loaderFile && loader && loader !== 'default' && loader !== 'custom') {\n  throw new Error('set images.loader to \"custom\" when using loaderFile');\n}","typeGuard":"function loaderFileCompatible(images: any): boolean {\n  return !images?.loaderFile || images?.loader === 'default' || images?.loader === 'custom' || !images?.loader;\n}","tryCatchPattern":null,"preventionTips":["When introducing loaderFile, switch loader to 'custom' in the same edit.","Lint for configs that have both a named loader and loaderFile."],"tags":["config","images","loader","loaderfile","next-config"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}