Nodejs: get filename of caller function

前端 未结 7 1221
心在旅途
心在旅途 2020-11-30 03:41

I wonder how-to get an absolute path of a caller of a function?

Let say that:

in file a.js I call b(); b() is a functi

7条回答
  •  借酒劲吻你
    2020-11-30 04:09

    Use https://github.com/sindresorhus/callsites

    If you use the first answer you could mess up with other libraries trying to do the same thing. See for example: https://github.com/facebook/jest/issues/5303

提交回复
热议问题