Difference between require, include, require_once and include_once?

There are require and include_once as well. So your question should be… When should I use require vs. include? When should I use require_once vs. require The answer to 1 is described here. The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a … Read more

NodeJs : TypeError: require(…) is not a function

I think this means that module.exports in your ./app/routes module is not assigned to be a function so therefore require(‘./app/routes’) does not resolve to a function so therefore, you cannot call it as a function like this require(‘./app/routes’)(app, passport). Show us ./app/routes if you want us to comment further on that. It should look something like this; You are exporting a function that can … Read more

The difference between “require(x)” and “import x”

This simple diagram will help you understand the difference between require and import. Apart from that, You can’t selectively load only the pieces you need with require but with import, you can selectively load only the pieces you need, which can save memory. Loading is synchronous(step by step) for require on the other hand import can be asynchronous(without waiting for previous import) so it can perform a little better … Read more