Next.js Discord

Discord Forum

can someone explain this weird require() behaviour?

Unanswered
Somali posted this in #help-forum
Open in Discord
SomaliOP
this is inside of a server-side components, any help? i'm trying to display different images based on a path specified in the component's props

    var imagePath = "./images/clothing-brand.png"

    var image = require(imagePath).default.src // cannot find module "./images/clothing-brand.png"

    image = require("./images/clothing-brand.png").default.src // returns successfully?

0 Replies