Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js module.exports函数运行并引发错误,即刚才运行的函数不存在_Node.js - Fatal编程技术网

Node.js module.exports函数运行并引发错误,即刚才运行的函数不存在

Node.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

当从module.exports函数调用module.exports函数时,脚本会运行从module.exports运行的函数,然后在node.js中抛出一个错误,指出即使已运行该函数,该函数也不存在

main.js
“严格使用”;
//工作或不工作所必需的东西。
恒战场=需要(“战场”);
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
}