Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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

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

// To export above functions:
module.exports = foo;
module.exports = bar;

// And in the file you want to use these functions,
// import them like this:
const foo = require('./module/path');
const bar = require('./module/path');

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #What #syntax #export #function #module
ADD COMMENT
Topic
Name
5+2 =