N
Nuxt2mo ago
Polak

NuxtImg not loading the images - error with IPX

Heya, I am having issues with the NuxtImg module. I can't seem to get the images to work. Have anyone experienced this before? Tried putting the images inside public folder but also assets. I check console and I get errors like shown in the images:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Failed to load resource: the server responded with a status of 404 (IPX_FILE_NOT_FOUND)
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Failed to load resource: the server responded with a status of 404 (IPX_FILE_NOT_FOUND)
Am I doing something wrong?
No description
No description
No description
No description
11 Replies
kapa.ai
kapa.ai2mo ago
Hi @Polak. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I can help you troubleshoot your NuxtImg loading issues. Based on the errors you're seeing, there are a few common problems that might be causing this: Issue 1: Image Location By default, the Nuxt Image module looks for images in the public/ directory. If your images are in the assets/ directory, you need to configure this explicitly:
// nuxt.config.ts
export default defineNuxtConfig({
image: {
dir: 'assets/images' // specify your images directory
}
})
// nuxt.config.ts
export default defineNuxtConfig({
image: {
dir: 'assets/images' // specify your images directory
}
})
This tells the IPX provider where to look for your source images Link to configuration docs. Issue 2: Image Path Format When using NuxtImg, make sure you're using the correct path format:
<!-- For images in public folder (default) -->
<NuxtImg src="/my-image.jpg" />

<!-- NOT this (common mistake) -->
<NuxtImg src="_nuxt/assets/img/my-image.jpg" />
<!-- For images in public folder (default) -->
<NuxtImg src="/my-image.jpg" />

<!-- NOT this (common mistake) -->
<NuxtImg src="_nuxt/assets/img/my-image.jpg" />
The path should be relative to the configured directory Link to providers docs. Issue 3: Sharp Installation The 500 error might indicate an issue with the Sharp package, which is used by IPX for image processing. This is especially common in production environments:
[500] [IPX_ERROR]
Something went wrong installing the "sharp" module
[500] [IPX_ERROR]
Something went wrong installing the "sharp" module
To fix this, you might need to: 1. Install Sharp explicitly in your project:
npm install sharp

npm install sharp

2. If deploying to a Linux server, you might need to rebuild Sharp for that platform:
npm rebuild --arch=x64 --platform=linux --libc=musl sharp

npm rebuild --arch=x64 --platform=linux --libc=musl sharp

This ensures the correct binary files are included for your production environment Link to Stack Overflow solution. Issue 4: Check Your Usage Make sure you're using the NuxtImg component correctly:
<NuxtImg
src="/my-image.jpg"
width="400"
height="300"
alt="My image description"
/>
<NuxtImg
src="/my-image.jpg"
width="400"
height="300"
alt="My image description"
/>
If you're still having issues, try using the IPX provider explicitly in your configuration:
export default defineNuxtConfig({
image: {
provider: 'ipx'
}
})
export default defineNuxtConfig({
image: {
provider: 'ipx'
}
})
Let me know if any of these solutions help with your specific case! GitHub: kapa.ai | Twitter: @kapa_ai | Made with 💛 by Kapa Team. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@260534435915628554> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Polak
PolakOP2mo ago
@kapa.ai none of the stuff worked
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I'm sorry to hear that none of the previous suggestions worked for your NuxtImg issue. Let's try some additional troubleshooting approaches: Additional Troubleshooting Steps 1. Check domains configuration - If you're using external images, make sure they're whitelisted:
// nuxt.config.ts
export default defineNuxtConfig({
image: {
domains: ['yourdomain.com']
}
})

// nuxt.config.ts
export default defineNuxtConfig({
image: {
domains: ['yourdomain.com']
}
})

You can also set this via environment variable: NUXT_IMAGE_DOMAINS="example.com,yourdomain.com" Link to providers docs 2. Try a different provider - You can specify a different provider directly in your component:
<NuxtImg
provider="cloudinary"
src="/your-image.jpg"
width="300"
height="169"
/>

<NuxtImg
provider="cloudinary"
src="/your-image.jpg"
width="300"
height="169"
/>

Link to provider usage 3. Move images to public folder temporarily - As a workaround, you could move your images to the public folder as mentioned in this Stack Overflow solution Link to Stack Overflow 4. Check for alias configuration - Make sure you don't have conflicting alias configurations:
// nuxt.config.ts
export default defineNuxtConfig({
image: {
alias: {
// your aliases here
}
}
})

// nuxt.config.ts
export default defineNuxtConfig({
image: {
alias: {
// your aliases here
}
}
})

Link to alias configuration 5. Try using a static image approach - If you're building a static site, you might need to prerender your images:
// nuxt.config.ts
export default defineNuxtConfig({
nitro: {
prerender: {
routes: [
'/_ipx/w_120/your-image.jpg',
// etc.
]
}
}
})

// nuxt.config.ts
export default defineNuxtConfig({
nitro: {
prerender: {
routes: [
'/_ipx/w_120/your-image.jpg',
// etc.
]
}
}
})

Link to static images docs If you're still experiencing issues, it would be helpful to know: - The exact error message you're seeing - Your Nuxt version - Your deployment environment (local, server type, etc.) - The exact code you're using for the NuxtImg component This would help provide more targeted troubleshooting steps for your specific situation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@260534435915628554> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Polak
PolakOP2mo ago
@kapa.ai Can I "disable" whatever NuxtImg does in the background?
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Yes, you can disable or bypass the image optimization that NuxtImg performs in the background. Based on your previous issues with IPX, here are a few approaches: Option 1: Use regular HTML img tag The simplest way to bypass NuxtImg is to use the standard HTML <img> tag instead:
<img src="/your-image.jpg" alt="Description" />
<img src="/your-image.jpg" alt="Description" />
This will completely bypass the image optimization pipeline. Option 2: Use the custom prop You can use the custom prop on NuxtImg to take control of the rendering while still having access to the computed values:
<NuxtImg
src="/your-image.jpg"
:custom="true"
v-slot="{ src, imgAttrs }"
>
<img
:src="'/your-image.jpg'"
alt="Description"
/>
</NuxtImg>
<NuxtImg
src="/your-image.jpg"
:custom="true"
v-slot="{ src, imgAttrs }"
>
<img
:src="'/your-image.jpg'"
alt="Description"
/>
</NuxtImg>
This gives you the flexibility to use your own image source path directly Link to NuxtImg custom prop. Option 3: Disable the module globally If you want to disable the image module entirely, you can remove it from your Nuxt modules in your nuxt.config.ts:
export default defineNuxtConfig({
modules: [
// Remove or comment out '@nuxt/image'
]
})
export default defineNuxtConfig({
modules: [
// Remove or comment out '@nuxt/image'
]
})
Option 4: Use the passThrough modifier with certain providers Some providers like ImageEngine support a passThrough modifier that will serve the unaltered image:
<NuxtImg
provider="imageengine"
src="/your-image.jpg"
:modifiers="{ passThrough: 'true' }"
/>
<NuxtImg
provider="imageengine"
src="/your-image.jpg"
:modifiers="{ passThrough: 'true' }"
/>
Link to ImageEngine provider These approaches should help you work around the IPX issues you're experiencing while still maintaining your site's functionality. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@260534435915628554> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Polak
PolakOP2mo ago
@kapa.ai So I tried using the default <img> and that works. How come NuxtImg doesnt work?
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on your experience where the standard <img> tag works but <NuxtImg> doesn't, there are several potential reasons for this issue: Common Reasons Why NuxtImg Fails While Regular img Works 1. Image Path Resolution
NuxtImg processes paths differently than the standard img tag. When using NuxtImg, the path should be relative to the configured directory (public by default):
<!-- Correct usage -->
<NuxtImg src="/my-image.jpg" />

<!-- Correct usage -->
<NuxtImg src="/my-image.jpg" />

Not with the full path that might work with regular img tags:
<!-- Problematic with NuxtImg -->
<NuxtImg src="_nuxt/assets/img/my-image.jpg" />

<!-- Problematic with NuxtImg -->
<NuxtImg src="_nuxt/assets/img/my-image.jpg" />

2. Directory Configuration By default, NuxtImg looks for images in the public/ directory. If your images are in assets/, you need to configure this explicitly:
// nuxt.config.ts
image: {
dir: 'assets/img'
}

// nuxt.config.ts
image: {
dir: 'assets/img'
}

As mentioned in a Stack Overflow solution, this configuration change can resolve 404 errors Link to Stack Overflow. 3. IPX Provider Issues NuxtImg uses the IPX provider by default for image processing, which requires the Sharp library. If Sharp isn't properly installed or configured, you'll get errors like:
[500] [IPX_ERROR]
Something went wrong installing the "sharp" module

[500] [IPX_ERROR]
Something went wrong installing the "sharp" module

This is a common issue in production environments Link to Stack Overflow. 4. Dynamic Image Imports If you're dynamically importing images, Nuxt3 handles this differently than Nuxt2. As noted in a Stack Overflow post, you might need to move images to the public folder as a workaround Link to Stack Overflow. Troubleshooting Steps 1. Check your browser console for specific error messages 2. Verify that your image paths are correct for NuxtImg 3. Make sure the Sharp library is properly installed 4. Try using a simple test case with an image definitely in the public folder If you're still experiencing issues, it might be worth sharing the specific error messages you're seeing for more targeted help. In the meantime, continuing to use the standard <img> tag is a perfectly valid workaround if NuxtImg is causing problems in your project. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@260534435915628554> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?