nodejs and es6 modules
////////////////////////////////////////////////////////////////
// Define and call a module method 1:
////////////////////////////////////////////////////////////////
// Custom_hello.js
var hello = function() {
console.log("hello!");
}
module.exports = hello;
// import and call the module in App.js
var hello = require("./custom_hello");
hello();
////////////////////////////////////////////////////////////////
// Define and call a module method 2:
////////////////////////////////////////////////////////////////
// Custom_goodbye.js
exports.goodbye = function(){
console.log("Bye!");
}
// import and call the module in App.js
var gb = require("./custom_goodbye");
gb.goodbye();
////////////////////////////////////////////////////////////////
// Define and call a module method 3:
////////////////////////////////////////////////////////////////
// moduleTest.js
var warn = function(message) {
console.log("Warning: " + message);
};
var info = function(message) {
console.log("Info: " + message);
};
var error = function(message) {
console.log("Error: " + message);
};
exports.warn = warn;
exports.info = info;
exports.error = error;