What is the syntax to export a function from a module in Node.js?

Viewed 11143

What is the syntax to export a function from a module in Node.js?

function foo() {}
function bar() {}

export foo; // I don't think this is valid?
export default bar;
4 Answers
export function foo(){...};

Or, if the function has been declared earlier:

export {foo};

Reference: MDN export

Related