Node.js从模块内部获取模块的文件名?
如何在加载过程中从模块内部获取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
。 这会得到你想要的。
如何在加载过程中从模块内部获取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
。 这会得到你想要的。