Implementing your module
In this recipe, we're going to start writing our module code. The module we will write will expose a single API that will reverse the sentence we pass to it. We'll also install a popular code formatter to keep our module code consistent.
Getting ready
Ensure you're in the reverse-sentence
folder and that package.json
is present, indicating that we have an initialized project directory.
We'll also need to create the first JavaScript file for our module:
$ touch index.js
How to do it
We're going to start this recipe by installing a popular code formatter to keep our module code styling consistent. By the end of this recipe, we will have created our first Node.js module using the following steps:
- First, let's add
prettier
as a code formatter for our module. When we know that other users are going to be consuming modules, it's important to have consistent and clearly formatted code so that the users...