'TypeError: is not a function' in Node.js

前端 未结 8 1843
礼貌的吻别
礼貌的吻别 2021-02-03 16:48

I\'m getting the error while running the following code in Node.js

var assert = require(\'assert\');
var request = require(\'request\');
var index = require(\'./         


        
8条回答
  •  遇见更好的自我
    2021-02-03 17:22

    I ran into the same problem while trying to follow a Nodejs tutorial by w3schools. I copied the following code from them:

    exports.myDateTime = function () {
    return Date();
    };
    

    That, however, wouldn't work for me. What resolved the problem for me was adding module. before the exports keyword like this:

    module.exports.myDateTime = function () {
    return Date();
    };
    

提交回复
热议问题