Categories
JavaScript Answers

How to fix ‘TypeError: is not a function’ error in Node.js?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *