- This is a simple workshop that will cover basic Node.js, Express, and Socket.io usage.
- You will be creating a web chat application and deploying it to the Cloud.
- Install NVM
- Install the latest version of Node.js:
nvm install 10 - Check that it worked:
node --versionandnpm --version - Update NPM to the latest version:
npm install --global npm
- If you are using Windows, you can use a Linux VM or...
- Install NVM for Windows
- Install the latest version of Node.js:
nvm install latest - Close and re-open Command Prompt
- Check that it worked:
node --versionandnpm --version - Update NPM to the latest version:
npm install --global npm
- Install
gitif you have not already. cdto the directory you want to install this repo in.- Clone this repo:
git clone https://github.com/SCUACM/node-workshop cdinto the newly creatednode-workshopdirectory.- If you
ls, you should be able to seepackage.json.
/package.json- File that specifies app details and dependencies for NPM./node_modules- Folder for all your app's NPM dependencies./public- Public-facing (client) code./public/scripts- Client Javascript (scripting)./public/stylesheets- Client CSS (styling)./public/index.html- Our frontend's main HTML file./server.js- Main file that holds all our server code.
- Install all node dependencies:
npm install. - You can check that it worked if
node_modulesfolder has been created. - Run
npm startto start your server.
- If you are looking for the completed code, check out the
solutionsbranch: - Online: https://github.com/SCUACM/node-workshop/tree/solutions
- Locally:
git checkout solutions(You might need togit stash)
- Create a free account at Heroku.
- Install Heroku's command-line tool based on your OS.
- Run
heroku loginand enter in your new Heroku account's credentials. - Run
heroku createto create a new Node.js instance. - Commit all your changes:
git add --all && git commit -m "Your message" - Run
git push heroku masterto send your changes to the Cloud! - View your instance on the web:
heroku open - If you make more changes, commit your new changes and re-push to Heroku.
- Single-threaded event loop
- Non-blocking I/O calls using libuv (async I/O)
- Because single-threaded, no thread context switching overhead (“fast”)
- Can’t scale Node.js by increasing the number of CPU cores, but can scale Node by increasing cluster size or upping the thread count in thread pool
- Promises
- New
async/awaitsyntax