Answer the question
In order to leave comments, you need to log in
TypeError: roulette.testFunc is not a function?
I ran into an incredible problem.
And it is incredible in that, in my opinion, there is nothing to break in it, because these are the basics, moreover, in other scripts of the same project, the same task is performed excellently, and in this one it is not.
It's about exporting a function and accessing it via require.
There is a test.js script and it lies along the path Site/routes/test.js.
The test function is defined in it like this:
function testFunc() {
return "Hello world!";
}
exports.testFunc = testFunc;
var test = require('../routes/test.js');
console.log(test.testFunc());
exports.Debug = function(msg) {
msg = GetDateTimeString() + " [DEBUG] " + msg;
console.log(msg);
fs.appendFile('logs.txt', msg + "\n", 'utf8', function (err) {
if(err) throw err;
});
}
Answer the question
In order to leave comments, you need to log in
either ring dependencies or redefining module.exports
if you provide the full test.js code, it will be more accurate
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question