繁体   English   中英

Node.js从模块内部获取模块的文件名?

[英]Node.js get file name of the module from inside the module?

如何在加载过程中从模块内部获取Node.js模块的名称?

//mymodule.js
console.log(GET_MODULE_FULL_PATH_NAME())

//prog.js

require('/full/path/module')
   OR
require('./module')
   OR
require('module.js')

使用__filename 那会得到你想要的。

http://nodejs.org/api/globals.html#globals_filename

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM