sindresorhus/import-modules

Cannot read property 'filename' of undefined

Closed this issue · 1 comments

I have the following index.js file:

import importModules from 'import-modules'

const modules = importModules('./test')

console.log(modules);

export default modules

In the same folder as the index.js file, there is a sub-folder test with multiple .js files.

But, the above code produces the following exception: "Cannot read property 'filename' of undefined"

This is the line that throws the error:

const parentFile = module.parent.filename;