To fix ‘TypeError: is not a function’ error in Node.js, we should make sure the variable is a function.
For instance, we write
module.exports = functionName
to export the functionName function in function.js.
Then we require it with
const functionName = require('./function')
Now we can call functionName in our code.