Let's say we want to create a module that converts HSL (hue, saturation, luminosity) values into a hex-based RGB representation, such as would be used in CSS (for example, #fb4a45).
The name hsl-to-hex seems good, so let's make a new folder for our module and cd into it:
mkdir hsl-to-hex
cd hsl-to-hex
Every Node module must have a package.json file, which holds metadata about the module.
Instead of manually creating a package.json file, we can simply execute the following command in our newly created module folder:
npm init
This will ask a series of questions. We can hit enter for every question without supplying an answer. Note how the default module name corresponds to the current working directory, and the default author is the init.author.name value we set earlier.
An npm init should look like this:
![](assets/a7c7463b-aada-418f-ace0-df2765d8c720.png)
Often times all the question defaults are just fine. Instead of hitting the enter key for every questions, we can run npm init -y to create a package.json file immediately, based on the defaults.
Upon completion, we should have a package.json file that looks something like the following:
{
"name": "hsl-to-hex",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "David Mark Clements",
"license": "MIT"
}