Using Modules and require can't find files in main asset folder

When trying to access files dynamically from a module ( by passing a list of filenames of local images in /assets/images to the module a-frame component ), the require function only seems to be able to find files in the modules own area ( eg /assets/images within the module itself ), rather than being able to look for files in eg the main projects /assets/images folder )

How can I access a project file from a module, when the filename of that local project file has been passed to the module.

This is for an image carasoul module, it’s used like this…

        image-carousel="imagePath: ./assets/delorean/images/photos/; images: a.jpg bc.jpg def.jpg ghij.jpg"

… where the images are stored in the projects folder, eg /assets/delorean/images/photos/a.jpg, and I’m trying to get the filename using this code from within the module ( which fails, as it can’t find it ).

const nextImageURL = require(imagePath + imageList[i])

When I run the component locally ( rather than as a module ), everything works great. I’d prefer to use modules, for sharing across projects etc.

1 Like

Hi Mal,
I was just checking out your module. Is there a docs on utilizing the module in any ways?