Search code examples
reactjswebpacknext.js

Nextjs: TypeError: unsupported file type: undefined after update to v.11


After update Next to 11 when I'm trying to load an image with:

import segmentLogoWhitePng from 'assets/images/my-image.png'

I'm getting the following error:

TypeError: unsupported file type: undefined (file: undefined)

Solution

  • Latest Update

    It works now as of [email protected]. No need to follow the steps below.


    Disable the static images feature for now as a workaround:

    // next.config.js
    
    module.exports = {
      images: {
        disableStaticImages: true
      }
    }
    

    Update: This has been fixed in [email protected]. Install it:

    $ npm install next@canary
    

    See the related issue & the PR.