The One Page, 7-minute Node Preface.
What is Node?
Setting up Node
Let’s install Node!
Step 1. Click on Install Node here: http://nodejs.org.
Step 2. Click Next, Agree to Software Agreement (if you’re on Windows), Next a couple more times, and Install
Step 3. Holy. You’re done! You have so much free time! Maybe read a book, or give some time to that favorite hobby of yours you’ve been neglecting.
Making sure Node is installed correctly
Let’s create a server!
Download the file here: http://6.470.scripts.mit.edu/day4/app.js
(right click, save to Desktop as 'app.js' without the quotations)
Move/Save the file onto your Desktop
PC: open up Node.js command prompt (should be in a Node.js folder in your All programs).
Mac: open up Terminal (in your Applications).
Navigate to your Desktop (most likely a command like: cd Desktop).
type the command: node app.js
In the command prompt/terminal, console.log should have logged a message. Visit that link (http://localhost:8000). If you open that in a web browser, you should be able to see a page. Congratulations, it worked! You’re done! Sit tight, and wait for tomorrow’s lecture.
Run the following commands:
npm install -g express
npm install -g express-generator
PC: Make sure you can run npm install
If you can't, and get an error like ENOENT stat: '<some folder name >', then you need to run mkdir <some folder name > so it will work. Make sure you're running the shell in Administrator mode!
Mac: Make sure you run both commands with sudo in front of it, e.g. sudo npm install -g express
On a PC?
See you tomorrow!