You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 9, 2024. It is now read-only.
I noticed an error while using this package with Node.js v16.13.2 1. Specifically, when not providing a filename myself, I'm seeing the error:
.../node_modules/eval/eval.js:38
var _filename = filename || module.parent.filename;
^
TypeError: Cannot read properties of undefined (reading 'filename')
at module.exports (.../node_modules/eval/eval.js:38:45)
at file:.../test.js:3:1
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:61:12)
This seems to me related to the fact that I'm using CommonJS code (namely this package) from ESModules code. Because ESModule doesn't use module, I'm guessing module.parent is undefined and hence the filename cannot be obtained.
The work-around is pretty simple (at least for now): just provide a filename. However, as the filename is optional in the API, I think it would make sense to find an alternative default filename to be used when none is provided - one that works when calling this package from ESModule code.