Intro to Node -- for SAFE Apps/ API's! :D

As I’m learning Node myself (so that I can use the bleeding-edge SAFE API’s), I thought I’d share my notes etc with anyone interested.

There was some talk here earlier about people getting into code, so I wanted to share what I learn about node as I learn it.

This first part is a real simple intro to Node and how to get your hands dirty with it. I will add more things when ready:

#What is NODEJS??


It takes JS (usually browser-only) and lets you use it on your PC!! As a real actual programming language like C#, Java etc!!

Now you can use JS like PHP / Ruby (which sucked and were always fragmented), which lets you access anything (network traffic, DB’s, files, etc) that is on your PC! JS no longer restricted only to accessing web page stuff!! opens it to everything

Can now create whole web servers too! no more php, ruby, python etc! Completely contained and self-serving web apps! JS (frontend) devs can now do BACKEND TOO!!

A whole website / app / company can be JS + NodeJS instead of JS + Java etc!


Test if you have it: node/npm -v and to start using it: node (will give a shell)

Made up of lots of “modules” and “npm” node package manager gets more 4u!

MAKE A QUICK NODE.JS APP!!: Make a file called “node1.js” etc and type “console.log(‘helloWorld’)” and then command line: “node node1.js” and your node app should run and say “helloWorld”!!!


make 2 separate ___.js files, and make the first say: “var modTest = require(’./module2’);”.

Then make the second one (the one gettin imported) say “var a = ‘ModImportSuccessful!’;” and also “console.log(a);” and when you command line: “node ___(firstFile)___.js” it should print that success message!! :smiley:

Using modules is EASY!! Also, GETTING modules is easy with NPM!! You can command line into ur folder and then just “npm install underscore” or anything you want, and it will get underscore for u, then “require(‘underscore’);” and “console.log(_);” and then when u run it, it will work and show u all the underscore commands avail! :smiley:


If u make a node project, u gotta add all the packages u used so that ur project will work on ppl’s computers!! So u gotta make a package.

Command “npm init” to make one, ENTER ENTER ENTER…etc and open the new “package.json” it made u! It should have a “dependencies” part that has all the packages that u made / “npm install”'ed!! Awesome!! (if not, sometimes gotta reinstall with ‘npm install ____ -S’).

GREAT!! :smiley: Now anyone can just get your whole node project from github, and do “npm install” and it will auto install all packages listed in the “package.json” and then work!!

Packages are what make Node so functional!! Lets u do sooo much crazy shiz with Node super easy!!


Get the Javascript file I made and then command line: “node Server!!.js” the file I made. The code is super easy and self-explanatory. Node includes that “http” toolkit for you that has those Server functions, requests and responses etc so it has everything u need to create and run a real live server in JS!! :smiley: :smiley:

Just run and go to localhost:3000 in your browser to see it working!! :smiley:

Can replace “hi” response with images, html pages, etc!! :smiley:

#EXPRESS.JS!! – coming real soon!


These are literally just my notes to myself that I made as I learn how to do different things.

Thought other people here might find them useful so I’ll continue adding to this if you guys want.

Feel free to ask any questions if you get stuck; I know it’s not the prettiest type of notes :slight_smile:


Great timing! Just getting back into my Node.js book yesterday. Keep em coming.


I have tried to make myself love JavaScript many times, but I just can’t! :slight_smile: Great to see others giving it some love though!


now THIS is worth bringing up :slight_smile:

1 Like

Gotta admit, letting frontend guys (like myself) easily start doing backend work is pretty empowering and amazing. NodeJS :smiley:

I think it exists not because ppl love JS but because more people know JS than any other programming language in the world, by far, so it’s the most worthwhile to expand

(but I’m mostly only learning it because it’s required by MaidSafe right now)



Here are some more Node.js Tutorials.


Wow, NodeJS! I can’t wait to try this one out. Now only Express, MongoDB and Angular and you can create yourself a MEAN App


lol, guess I got busy :stuck_out_tongue:

1 Like