Learning Node.JS
This beautiful sunny weekend in London I decided to stay in and learn “PostCSS’...there was mentions of modules and similarities now instead I’m learning Node.JS. I figured if, I can get a fundamental understanding of what it is and how it works exactly, I’ll be in better position to understand “Post CSS”...
yeah...sounds about right.
I have a basic understanding of javascript, very basic understanding of Terminal, and a basic understanding of Github. The hope is, that while learning Node.JS, I’ll be able to understand more of these other tools in my use of it during this experience.
Shout out to the book I’m using to guide me through the process!
‘Sams Teach Yourself Node.JS in 24 Hours by George Ornbo’.
It’s speaking my language in terms of my level of understanding, and satisfies the feeling of accomplishment by having you build something small every chapter using it. I’m starting to gain momentum going the first two chapters so I think this might be a good time to document my journey.
I loaded my first server--relatively, pretty simple.
Following the instructions on the book, I already had node dl’d. I opened my Sublime Text Editor separately and saved the files under my computer name. This book was written a couple years ago, so when it came to the examples, I googled instead 2016 instructions from The Node Beginner and copied the coding from there vs from the book that has some ancient written texts on it, lol:
Modules
I have since moved on to familiarizing myself with the concept of modules and checked out the IRC database. Following the instructions of the book to also check them out via terminal--
(It scrolls for days)
While this gives me a sense of accomplishment, its mostly false as I still don’t get how they are used in context.
I then used one for my own module called underscore--I think:
Terminal results after naming the file foo.js:
Moving forward to JSON packages!
The next exercise had me open another file in the text editor and copy and paste ancient code--that would allow me to store all my ‘dependencies and modules in one place’. However, I believe it wasn’t updated or I didn’t fill in the info in the text editor, so this happened--
Fortunately, they are not deal breakers, but more like a ‘heads up! this sucks’
Meh. Moving on! Exercises:
I got through the workshop and exercises at the end of this second chapter. Used npm search to search for a template engine
npm search template engine
...A bazillion packages displayed on the terminal.
Then installed ‘coffee-script’ using the search first to see the options. Then got stuck at installing ‘express’---
Problem: npm install -g express -- the -g should install it globally ( so it can be accessed from anywhere, not just a specific project file). By default, when you install modules, it’s stored locally in a ‘node-modules’ file. Of which, I noticed, despite my use of -g, it kept being stored under:
^Stored in node_modules...so then when I try to call it from outside the folder, I get this:
Googled “can’t install express globally”. Landed on this Stack Overflow Page that had the answer: sudo npm install -g express-generator
...and now it works!
Next up: Learning the Context of Node.JS: Chapter 3: What is Node.JS Used for













