Scaffolding a module
Let's begin our exploration setting up a typical file and structure for a Node module. At the same time, we'll be learning how to automatically generate a package.json
file (we refer to this throughout the book as initializing a folder as a package). We'll also configure npm
(Node's package managing tool) with some defaults, which can then be used as part of the package generation process.
In this recipe, we'll create the initial scaffolding for a full Node module.
Getting ready
Note
Installing Node
If we don't already have Node installed, we can go to nodejs.org to pick up the latest version for our operating system.
If Node is on our system, then so is the npm
executable; npm
is the package manager for Node. It's useful for creating, managing, installing, and publishing modules.
Before we run any commands, let's tweak the npm
configuration a little:
npm config set init.author.name "<name here>"
This will speed up module creation and ensure that package we create...