twopluszero / next-images

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

TypeError: Cannot convert undefined or null to object #84

Open jmorey28 opened 2 years ago

jmorey28 commented 2 years ago

I am using withImages as documented in the Expo documentation but am getting TypeError: Cannot convert undefined or null to object.

Here is the link to the documentation https://docs.expo.dev/guides/using-nextjs/#image-support

And here is the implementation:

const { withExpo } = require("@expo/next-adapter");
const withImages = require("next-images");

module.exports = withExpo(
  withImages({
    projectRoot: __dirname,
  })
);
gregogalante commented 2 years ago

I have the same problem!

theartofnonso commented 2 years ago

I am facing the same issue as well.

I have followed the instructions in the docs.

The problem is because withImages() is not being recognised as a function

@jmorey28 @gregogalante did you manage to fix it?

Cheers

acrabb commented 2 years ago

Same issue here 😭 "next-images": "^1.8.4",

smnchoi commented 1 year ago

This config works for me. cheers.

// @generated: @expo/next-adapter@2.1.52
// Learn more: https://docs.expo.io/guides/using-nextjs/

const { withExpo } = require("@expo/next-adapter");
const withPlugins = require("next-compose-plugins");
const withTM = require("next-transpile-modules")(["react-native-web"]);
const withImages = require("next-images");

module.exports = withPlugins(
  [
    withTM,
    [withExpo, { projectRoot: __dirname }],
    [
      withImages,
      {
        projectRoot: __dirname,
        // fileExtensions: ["png"],
        // disableStaticImages: true,
        // esModule: true,
        images: {
          fileExtensions: ["png"],
          disableStaticImages: true,
          //   esModule: true,
        },
      },
    ],
  ],
  {}
);