PayU / prometheus-api-metrics

API and process monitoring with Prometheus for Node.js micro-service
Apache License 2.0
130 stars 44 forks source link

Cannot read property 'filename' of undefined #34

Open Fi1osof opened 4 years ago

Fi1osof commented 4 years ago

prometheus-api-metrics/src/index.js:5:73

node started with --experimental-modules, there no module object. Path.dirname(module.parent.filename)

Maybe use dir: process.cwd() instead?

carlossuds commented 3 years ago

I'm having the sabe problem. DId you find any solution?

Fi1osof commented 3 years ago

@carlossuds, sorry, no. I do not use this any more.

alucryd commented 2 years ago

Still a thing unfortunately, not well-versed enough in JS yet, but if I find something I'll make a PR. In the meantime, express-prometheus-middleware works for me, so you can use that on instead.

Edit: You can use this trick https://dev.to/jimthedev/typeerror-cannot-read-property-filename-of-undefined-in-es-modules-in-node-14-and-greater-6ia