twopluszero / next-images

Import images in Next.js (supports jpg, jpeg, svg, png and gif images)
MIT License
948 stars 67 forks source link

I see this error TypeError: unsupported file type: undefined (file: undefined), after 11 -> 12 migration, can you help me? #83

Closed mxomxo77mxo closed 2 years ago

mxomxo77mxo commented 2 years ago

image

beinoriusju commented 2 years ago

How did you solve this?

fcolacilli commented 2 years ago

This worked for me:

In next.config.js:

const withImages = require("next-images");

module.exports = withImages({
  images: {
    disableStaticImages: true,
  },
});

And then, in the images I had with src={StaticImage.src}, I changed them to src={StaticImage}.

Then, I also had a vscode warning about static images types, which I solved with this.