Get started with Node.js and Express

September 2015 · 2 minute read

These are the simplest current resources to get you up and running with a skeleton Node.js app using command line on mac osx and run a simple skeleton app locally in a dir that you choose. See the references, use specifically the commands below in order.

1. Cd in the dir you wish to use

If permissions are denied this command can override root. BE CAREFUL

http://superuser.com/questions/254843/cant-install-brew-formulae-correctly-permission-denied-in-usr-local-lib

$ sudo chown -R $(whoami) ~/.npm

2. Update homebrew

https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/FAQ.md

$ brew doctor $ brew upgrade

3. Install nvm

http://dandean.com/nodejs-npm-express-osx/

$ brew install nvm

$ mkdir ~/.nvm

$ cp $(brew –prefix nvm)/nvm-exec ~/.nvm/

$ export NVM_DIR=~/.nvm

$ source $(brew –prefix nvm)/nvm.sh

4. Update nvm and with the latest version of node**

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.27.1/install.sh

$ nvm install 0.10

$ nvm use 0.10

$ nvm install node –reinstall-packages-from=node

5. Cd into the dir you wish to use

$ cd selenasmall/devroot/node

6. Install Express and the Express skeleton app (really good example)

https://quickleft.com/blog/getting-started-with-express-in-node/

$ npm install -g express

$ express -h

$ express express-skeleton

$ ls

$ cd express-skeleton/

$ cd express-skeleton && npm install

$ DEBUG=express-skeleton:* npm start

7. Test it out

http://localhost:3000/

https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

$ git init

$ git add .

$ git commit -m ‘first commit’

$ git remote add origin git@github.com:url.git

$ git remote -v

$ git push origin master

Working example: https://github.com/SelenaSmall/node-express/commits/master