nextjs - 💡(How to fix) Fix Image Component with custom loader failed on Windows DEV environment with Turbopack setup [4 comments, 5 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85429Fetched 2026-04-08 02:15:48
View on GitHub
Comments
4
Participants
5
Timeline
18
Reactions
9
Author
Timeline (top)
subscribed ×5commented ×4labeled ×3cross-referenced ×2

Error Message

With above step recreation, nextjs with turbopack will throw Runtime Error: Runtime Error

Code Example

import type { ImageLoaderProps } from 'next/image';

export default function ImagePgw({
  src,
  width,
  quality,
}: ImageLoaderProps): string {
  return `https://my-custom-image/gw/photo.php?u=${src}&sl=W&fw=${width}&nt=1&q=${quality}`;
}

};

export default nextConfig;

---

import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
  images: {
    loader: 'custom',
    loaderFile: './lib/image.ts',
  },
};

export default nextConfig;

---

Runtime Error

Image with src "/next.svg" is missing "loader" prop.
Read more: https://nextjs.org/docs/messages/next-image-missing-loader

---

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32490
  Available CPU cores: 16
Binaries:
  Node: 20.19.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.0 // Latest available version is detected (16.0.0).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/p6llq9

To Reproduce

  1. Install Nextjs 16 with default settings in Windows npx create-next-app@latest next-app --yes
  2. Create a custom loader for Image, e.g inside ./lib/image.ts, with simple return statement:
import type { ImageLoaderProps } from 'next/image';

export default function ImagePgw({
  src,
  width,
  quality,
}: ImageLoaderProps): string {
  return `https://my-custom-image/gw/photo.php?u=${src}&sl=W&fw=${width}&nt=1&q=${quality}`;
}

};

export default nextConfig;
  1. Configure next.config.ts
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
  images: {
    loader: 'custom',
    loaderFile: './lib/image.ts',
  },
};

export default nextConfig;
  1. Run npm run dev

Current vs. Expected behavior

With above step recreation, nextjs with turbopack will throw Runtime Error:

Runtime Error

Image with src "/next.svg" is missing "loader" prop.
Read more: https://nextjs.org/docs/messages/next-image-missing-loader

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32490
  Available CPU cores: 16
Binaries:
  Node: 20.19.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.0 // Latest available version is detected (16.0.0).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Image (next/image)

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

It works well using webpack setup, and also work well on Linux/WSL with turbopack setting, it seems like there is some missing configuration on Windows Env, the above codesandbox work well, but i can't reproduce an example using Windows Env

extent analysis

TL;DR

  • The issue can be resolved by ensuring the custom image loader is properly configured and recognized by Next.js in a Windows environment.

Guidance

  • Verify that the next.config.ts file is correctly configured to use the custom image loader by checking the images.loader and images.loaderFile properties.
  • Check the file path and name of the custom loader (./lib/image.ts) to ensure it matches the configuration in next.config.ts.
  • Try to reproduce the issue in a minimal example using the same Next.js and Node.js versions to isolate the problem.
  • Consider comparing the differences in configuration or environment between the working Linux/WSL setup and the non-working Windows setup.

Example

// next.config.ts
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
  images: {
    loader: 'custom',
    loaderFile: './lib/image.ts', // Ensure this path is correct
  },
};

export default nextConfig;

Notes

  • The issue seems to be specific to the Windows environment, as it works well on Linux/WSL with the same configuration.
  • The provided codesandbox example works, which suggests that the issue might be related to the local environment or configuration.

Recommendation

  • Apply workaround: Try to use a relative path or an absolute path for the loaderFile property in next.config.ts to ensure the custom loader is correctly loaded.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix Image Component with custom loader failed on Windows DEV environment with Turbopack setup [4 comments, 5 participants]