Node.js module.exports函数运行并引发错误,即刚才运行的函数不存在
当从module.exports函数调用module.exports函数时,脚本会运行从module.exports运行的函数,然后在node.js中抛出一个错误,指出即使已运行该函数,该函数也不存在 main.jsNode.js module.exports函数运行并引发错误,即刚才运行的函数不存在,node.js,Node.js,当从module.exports函数调用module.exports函数时,脚本会运行从module.exports运行的函数,然后在node.js中抛出一个错误,指出即使已运行该函数,该函数也不存在 main.js “严格使用”; //工作或不工作所必需的东西。 恒战场=需要(“战场”); const math=require('mathjs'); 常数fs=要求('fs'); 变量配置,api,argv=false; if(fs.existsSync(“config.json”)){ con
“严格使用”;
//工作或不工作所必需的东西。
恒战场=需要(“战场”);
const math=require('mathjs');
常数fs=要求('fs');
变量配置,api,argv=false;
if(fs.existsSync(“config.json”)){
config=require('./config.json');
api=新战场(配置api_键);
argv=process.argv;
require('./modules/misc.js').startPUBGNode(配置,argv);
}else{console.error(“config.json不存在,请创建它或从github重新下载导出对象时调用函数,在本例中是错误的
试试这个
module.exports = {
help: help,
prog_setup: prog_setup,
latestmatchidfromusername: latestmatchidfromusername,
getplayerinfo: getplayerinfo,
cleanup: cleanup,
exportashtmlfromuname: exportashtmlfromuname,
exportashtml: exportashtml,
getlatestmatchfromusername: getlatestmatchfromusername,
getmatchdata: getmatchdata
}
prog\u setup:prog\u setup()
您在分配属性时调用函数。就像在链接问题中一样,您将()
放在函数名之后,当您只需要传递函数时立即调用它。这是完全相同的问题。
module.exports = {
help: help,
prog_setup: prog_setup,
latestmatchidfromusername: latestmatchidfromusername,
getplayerinfo: getplayerinfo,
cleanup: cleanup,
exportashtmlfromuname: exportashtmlfromuname,
exportashtml: exportashtml,
getlatestmatchfromusername: getlatestmatchfromusername,
getmatchdata: getmatchdata
}