Bringing in other node packages
Node.js prides itself on creating small, bordering on tiny, packages, and has the excellent npm package manager (and others) to help manage those packages. Because the Raspberry Pi runs a full version of Node.js, we can leverage that to our advantage and bring in other packages in order to build more interesting projects.
Project – building a rainbow
Can you remember the RGB code for orange off the top of your head? I can't. It's easier to remember to convert the color systems we do know into RGB (especially names such as red, orange, and cornflower blue). But instead of building a function to convert it for us, we'll leverage what I call Stilwell's law: if you've thought of it, it's probably on npm already. True to form, the color module is going to help us out.
Using the color npm module
In order to use the color npm
module, first we will install it. In your SSH session, in your project
folder, run the following code:
npm i --save color
This will also save...