Previous Lecture Complete and continue  


Topics Covered

  • Review of how we manage 3rd party modules in the browser
  • Convert a simple script from the web to node
  • Using NPM to install our dependencies rather than a CDN via script tag

Example Code

In Node.js we don’t have access to the DOM so we can not load our 3rd party modules with a CDN. In Node.js we need to use NPM which is a registry hosting 3rd party JavaScript which allows us to download locally to run within our Node.js environment.

From Browser


<!DOCTYPE html>
  <main>Hello World</main>
  <script src=""></script>
  <script src="app.js"></script>


// <script src="underscore.js"> tag for underscore
var instructors = ['PatrickJS', 'Scott Moss', 'Mike Adams'];
_.each(instructors, function(person) {
  console.log('Hello', person);


To Node.js


var _ = require('underscore');
_.each(instructors, function(person) {
  console.log('Hello', person);