Yesterday left off with learning what a module is. A module is a reusable block of code whose existence does not accidentally impact other code.
Today first we downloaded node.js from their website and made sure our computer had it installed with a command “node -v” in the command line. This returns the version of node.js is installed.
That was essentially my first module created in node.js. The course took it a step further by changing the console.log module into a function. By changing the module into a function I discovered that you cannot call the function in the main.js file even though you have the module imported. That’s the beauty of modules it doesn’t allow you to impact other code. This allows for fewer errors to be made if fewer things affect each other.
However, there is a way to get certain functions and object properties from a module. There is a special function you can use within the module file called module.exports. Then I set the export function equal to the function or object that you want to pull data from.