Ask coding questions

← Back to all posts
TypeError: require(...) is not a function
hazelpy (8)

When I attempt to use require() in a Nodejs repl, it throws the error in the title. What am I doing wrong?

MrEconomical (2289)

require is not a function because you are trying to call the thing you required like a function example: a = require("a"); a() <- this might throw an error because a itself might not be a function, this is equivalent of putting require("a")()

so the thing you are trying to require might not be a function