我发现x不是javascript中的函数

我发现x不是javascript中的函数,javascript,node.js,command-line,error-handling,Javascript,Node.js,Command Line,Error Handling,我编写了一个简单的程序,其中编写了如下所示的java脚本函数 函数添加(num1,num2){ 返回num1+num2; } 模块.导出={ 添加 } console.log(添加(5,4))如果以错误的方式导出模块,请将其更改为 module.exports = { add }; //with the final s 您以错误的方式导出模块,请将其更改为 module.exports = { add }; //with the final s 你是如何运行这个逻辑的?在web中?尝试mo

我编写了一个简单的程序,其中编写了如下所示的java脚本函数

函数添加(num1,num2){
返回num1+num2;
}
模块.导出={
添加
}

console.log(添加(5,4))如果以错误的方式导出模块,请将其更改为

module.exports = { add }; //with the final s

您以错误的方式导出模块,请将其更改为

module.exports = { add }; //with the final s

你是如何运行这个逻辑的?在web中?尝试module.exportsHow是否运行此逻辑?在web中?试试module.exports它工作得很好,谢谢karim,我在过去两个小时里一直坚持使用它很好,很高兴它起到了作用:)工作得很好,谢谢karim,我在过去两个小时里一直坚持使用它很好,很高兴它起到了作用:)