In node.JS how can I get the path of a module I have loaded via require that is *not* mine (i.e. in some node_module)

前端 未结 7 1762
清歌不尽
清歌不尽 2020-12-02 15:16

I require a module that was installed via npm. I want to access a .js file subordinate to that module (so I can subclass a Constructor method in it). I can\'t (well, don\'t

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 15:31

    This is maybe what you're looking for, check:

    require.main.filename

提交回复
热议问题