Slide 1

Slide 1 text

M O D U L E D E V E L O P M E N T

Slide 2

Slide 2 text

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. “ ” What is node.js?

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

./

Slide 5

Slide 5 text

sourceControl git  init

Slide 6

Slide 6 text

javascriptFiles mkdir  ./lib

Slide 7

Slide 7 text

executableFiles mkdir  ./bin

Slide 8

Slide 8 text

testFiles mkdir  ./test

Slide 9

Slide 9 text

documentationFiles mkdir  ./doc mkdir  ./example mkdir  ./man

Slide 10

Slide 10 text

informationalFiles touch  ./README touch  ./LICENSE touch  ./AUTHOR

Slide 11

Slide 11 text

./bin ./doc ./example ./lib ./man ./test singularNouns

Slide 12

Slide 12 text

packageManagement

Slide 13

Slide 13 text

Package Manager

Slide 14

Slide 14 text

github: install: isaacs/npm comes with node

Slide 15

Slide 15 text

npm install localInstallation

Slide 16

Slide 16 text

npm install --global globalInstallation -g or --global

Slide 17

Slide 17 text

npm install --link dualInstallation

Slide 18

Slide 18 text

npm install --save[-dev] dependencyReferences --save or --save-dev

Slide 19

Slide 19 text

npm install updateDependencies

Slide 20

Slide 20 text

npm init packageInitialization

Slide 21

Slide 21 text

$  npm  init name: (sample-node) Sample version: (0.0.0) 0.1.0 description: This is a sample module entry point: (index.js) _

Slide 22

Slide 22 text

author:  Jay  Harris license:  (BSD)  BSD About  to  write  to  /Projects/sample-­‐node/package.json: {    "name":  "Sample",    "version":  "0.1.0",    "description":  "This  is  a  sample  module",    "main":  "index.js",    "scripts":  {        "test":  "echo  \"Error:  no  test  specified\"  &&  exit  1"    },    "author":  "Jay  Harris",    "license":  "BSD" } Is  this  ok?  (yes)  _

Slide 23

Slide 23 text

./package.json { "name": "Sample", "version": "0.1.0", "description": "This is a sample module", "main": "index.js", "scripts": { "test": "echo \"Error: no tests avail.\" && exit 1" }, "author": "Jay Harris", "license": "BSD" } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Slide 24

Slide 24 text

npm init is additive not destructive

Slide 25

Slide 25 text

moduleCreation

Slide 26

Slide 26 text

module

Slide 27

Slide 27 text

module.exports

Slide 28

Slide 28 text

./lib/sample.js module.exports.sayHello = function() { return "Hello World!"; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Slide 29

Slide 29 text

var  sample  =  require("./lib/sample.js"); //  Returns  'Hello  World!' sample.sayHello();

Slide 30

Slide 30 text

./lib/person.js function Person(first, last) { if (!(this instanceof Person)) { return new Person(first, last); } this.firstName = first; this.lastName = last; return this; } module.exports = Person; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Slide 31

Slide 31 text

var person = require("./lib/person.js"); // This will return undefined person.firstName; // This will return 'Jay' var jayHarris = new Person('Jay','Harris'); jayHarris.firstName;

Slide 32

Slide 32 text

function Person(first, last) { // ... } module.exports = Person; // This is a public method; Person.prototype.sayHello = function() { return _join.call(this, "Hello", this.firstName); } // This is a private method var _join(first, second) { return first + ' ' + second; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 33

Slide 33 text

var  person  =  require("./lib/person.js"); //  This  will  throw  'Has  No  Method'  error person.sayHello(); //  This  will  return  'Hello  Jay' var  jayHarris  =  new  Person('Jay','Harris'); jayHarris.sayHello();

Slide 34

Slide 34 text

function Person(first, last) { // ... } module.exports = Person; // This is a static method module.exports.sayHello = function() { return "Hello World!"; } // This is a public instance method; Person.prototype.sayHello = function() { return _join.call(this, "Hello", this.firstName); } // This is a private method var _join(first, second) { return first + ' ' + second; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 35

Slide 35 text

var  person  =  require("./lib/person.js"); //  This  will  return  'Hello  World!' person.sayHello(); //  This  will  return  'Hello  Jay' var  jayHarris  =  new  Person('Jay','Harris'); jayHarris.sayHello();

Slide 36

Slide 36 text

eventEmitter

Slide 37

Slide 37 text

var  EventEmitter  =  require('events').EventEmitter;

Slide 38

Slide 38 text

EventEmitter.call(this);

Slide 39

Slide 39 text

var  util  =  require('util'); //  ... util.inherits(MyClass,  EventEmitter);

Slide 40

Slide 40 text

var EventEmitter = require('events').EventEmitter , util = require('util'); function Person(first, last) { // ... EventEmitter.call(this); // ... } util.inherits(Person, EventEmitter); Person.prototype.goToBed = function() { this.emit("sleep"); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 41

Slide 41 text

var  person  =  require("./person.js"); //  This  will  return  'Hello  Jay' var  jayHarris  =  new  Person('Jay','Harris'); jayHarris.on("sleep",  function()  {        console.log("Goodnight,  Jay"); } jayHarris.goToBed(); //  Output  'Goodnight,  Jay'

Slide 42

Slide 42 text

testingNode.js

Slide 43

Slide 43 text

TDD is to coding style as yoga is to posture. Even when you're not actively practicing, having done so colors your whole life healthier.” j. kerr “

Slide 44

Slide 44 text

assertingCorrectness

Slide 45

Slide 45 text

var  assert  =  require('assert');

Slide 46

Slide 46 text

assert(value)            .ok(value)            .equal(actual,  expected)            .notEqual(actual,  expected)            .deepEqual(actual,  expected)            .notDeepEqual(actual,  expected)            .strictEqual(actual,  expected)            .notStrictEqual(actual,  expected)            .throws(block,  [error])            .doesNotThrow(block,  [error])            .ifError(value)

Slide 47

Slide 47 text

var assert = require('assert'); // Will pass assert.ok(true); // Will throw an exception assert.ok(false); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 48

Slide 48 text

var assert = require('assert'); // Will throw 'false == true' error assert.ok(typeof 'hello' === 'number'); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 49

Slide 49 text

$  node  test.js assert.js:104    throw  new  assert.AssertionError({                ^ AssertionError:  false  ==  true        at  Object.  (my-­‐test.js:7:8)        at  Module._compile  (module.js:449:26)        at  Object.Module._extensions..js  (module.js:467:10)        at  Module.load  (module.js:356:32)        at  Function.Module._load  (module.js:312:12)        at  Module.runMain  (module.js:487:10)        at  process.startup.processNextTick.process._tick... $  _

Slide 50

Slide 50 text

Chai Assertion Library

Slide 51

Slide 51 text

github: install: chaijs/chai npm install chai

Slide 52

Slide 52 text

isTrue,                      isFalse, isNull,                      isNotNull, isUndefined,            isDefined, isFunction,              isNotFunction, isArray,                    isNotArray, isBoolean,                isNotBoolean, isNumber,                  isNotNumber, isString,                  isNotString,                                    include,                                    lengthOf,                                    operator,                                    closeTo   isObject,                  isNotObject, typeOf,                      notTypeOf, instanceOf,              notInstanceOf, match,                        notMatch, property,                  notProperty, deepProperty,          notDeepProperty, propertyVal,            propertyNotVal, deepPropertyVal,    deepPropertyNotVal, additional assertions

Slide 53

Slide 53 text

var  assert  =  require('chai').assert;

Slide 54

Slide 54 text

var assert = require('chai').assert; // Will throw 'expected 'hello' to be a number' assert.isNumber('hello'); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 55

Slide 55 text

$  node  test.js expected  'hello'  to  be  a  number $  _

Slide 56

Slide 56 text

var chai = require('chai') , assert = chai.assert; chai.Assertion.includeStack = true; // Will throw and display stack assert.isNumber('hello'); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 57

Slide 57 text

expectAssertions

Slide 58

Slide 58 text

expectSyntax expect(person).to.be.an('object');        .with.property('age')        .that.is.a('number')        .that.equals(34); assert.isObject(person); assert.property(person,  "age"); assert.isNumber(person.age); assert.equals(person.age,  34); assertSyntax

Slide 59

Slide 59 text

var  expect  =  require('chai').expect;

Slide 60

Slide 60 text

assertionChains for readability

Slide 61

Slide 61 text

expect(person).to.exist        .and.be.an('object')        .with.property('age')        .that.is.to.exist        .and.is.a('number')        .and.equals(34);

Slide 62

Slide 62 text

.to .be .been .is .that .and .have .with syntaxSugar for readability

Slide 63

Slide 63 text

expect(person).to.exist        .and.be.an('object')        .with.property('age')        .that.is.to.exist        .and.is.a('number')        .and.equals(34);

Slide 64

Slide 64 text

expect(person).to.exist        .and.be.an('object')        .with.property('age')        .that.is.to.exist        .and.is.a('number')        .and.equals(34);

Slide 65

Slide 65 text

.property subjectChange from original object

Slide 66

Slide 66 text

expect(person)    .that.is.an('object')    .with.property('address')        .that.is.an('object')        .with.property('city')            .that.is.a('string')            .and.equals('Detroit')

Slide 67

Slide 67 text

testingFramework

Slide 68

Slide 68 text

mocha simple, flexible, fun

Slide 69

Slide 69 text

mocha github: install: visionmedia/mocha npm install -g mocha

Slide 70

Slide 70 text

$  npm  install  -­‐g  mocha $  mkdir  test $  mocha        ✔  0  tests  complete  (1ms) $  

Slide 71

Slide 71 text

var  mocha  =  require('mocha');

Slide 72

Slide 72 text

describe('Testing  out  this  thing',  function()  {        it('should  do  stuff',  function()  {                //  Assertion  tests        }); }); bddSyntax

Slide 73

Slide 73 text

./test/my-test.js var assert = require('assert'); describe('Assertions', function() { it('should pass on truthiness', function() { assert.ok(true); }); it('should fail on falsiness', function() { assert.ok(false); }); }); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Slide 74

Slide 74 text

$  mocha  -­‐-­‐reporter  spec    Assertions        ✓  should  pass  on  truthiness          1)  should  fail  on  falsiness    ✖  1  of  2  tests  failed:    1)  Assertions  should  fail  on  falsiness:              AssertionError:  false  ==  true            at  (stack  trace  omitted  for  brevity) $  _

Slide 75

Slide 75 text

groupedTests

Slide 76

Slide 76 text

describe('Testing  out  this  thing',  function()  {        describe('with  a  subset  of  this  other  thing',  function()  {                it('should  do  stuff',  function()  {                        //  Assertion  tests                });        }); }); groupSyntax

Slide 77

Slide 77 text

var expect = require('chai').expect; describe('Assertions', function() { describe('on equality', function() { it('should pass on truthiness', function() { expect(true).is.true; }); it('should pass on falsiness', function() { expect(false).is.false; }); }); describe('on type', function() { it('should pass on number', function() { expect(5).is.a('number'); }); }); }); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 78

Slide 78 text

$  mocha  -­‐-­‐reporter  spec    Assertions        of  equality            ✓  should  pass  on  truthiness              ✓  should  pass  on  falsiness          on  type            ✓  should  pass  on  number      ✔  3  tests  complete  (6ms) $  _

Slide 79

Slide 79 text

pendingTests

Slide 80

Slide 80 text

describe('Testing  out  this  thing',  function()  {        describe('with  a  subset  of  this  other  thing',  function()  {                it('should  do  stuff  someday');        }); }); pendingSyntax

Slide 81

Slide 81 text

var assert = require('chai').assert; describe('Assertions', function() { describe('of truthiness', function() { it('should pass on truthiness', function() { expect(true).is.true; }); it('should pass on falsiness', function() { expect(false).is.false; }); }); describe('of type', function() { it('should pass on number', function() { expect(5).is.a('number'); }); it('should pass on object'); }); }); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 82

Slide 82 text

$  mocha  -­‐-­‐reporter  spec    Assertions        of  truthiness            ✓  should  pass  on  truthiness            ✓  should  pass  on  falsiness        of  type            ✓  should  pass  on  number              -­‐  should  pass  on  object    ✔  4  tests  complete  (6ms)    •  1  test  pending $  _

Slide 83

Slide 83 text

skippedTests

Slide 84

Slide 84 text

describe('Testing  out  this  thing',  function()  {        it.skip('should  be  skipped',  function()  {                //  Assertion  tests        }); }); describe.skip('This  entire  suite  will  be  skipped',  function()  {        it('should  do  stuff',  function()  {                //  Assertion  tests        }); }); skipSyntax

Slide 85

Slide 85 text

describe('Assertions', function() { describe('of truthiness', function() { it('should pass on truthiness', function() { assert.isTrue(true); }); it('should pass on falsiness', function() { assert.isFalse(false); }); }); describe('of type', function() { it.skip('should pass on number', function() { assert.isNumber(5); }); it('should pass on object'); }); }); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 86

Slide 86 text

$  make  test    Assertions        of  truthiness            ✓  should  pass  on  truthiness              ✓  should  pass  on  falsiness          of  type            -­‐  should  pass  on  number              -­‐  should  pass  on  object    ✔  4  tests  complete  (6ms)    •  2  test  pending $  _

Slide 87

Slide 87 text

setupTeardown

Slide 88

Slide 88 text

before(); beforeEach(); after(); afterEach();

Slide 89

Slide 89 text

describe('Testing  out  this  thing',  function()  {        before(function(){                //  ...        };        describe('with  a  subset  of  that  thing',  function()  {                it('should  do  stuff',  function()  {                        //  Assertion  tests                });                afterEach(function(){                        //  ...                };        }); }); setupTeardown

Slide 90

Slide 90 text

asynchronousTests

Slide 91

Slide 91 text

it('should  not  error',  function(done)  {        search.find("Apples",  done); }); asynchronousSyntax

Slide 92

Slide 92 text

it('should  not  error',  function(done)  {        search.find("Apples",  done); }); it('should  return  2  items',  function(done)  {        search.find("Apples",  function(err,  res)  {                if  (err)  return  done(err);                res.should.have.length(2);                done();        }); }); asynchronousSyntax

Slide 93

Slide 93 text

All Mocha functions accept this callback

Slide 94

Slide 94 text

describe('When searching for Apples', function(done) { before(function(done){ items.save(['fiji apples', 'empire apples'], done); }); it('should not error', function(done) { search.find("Apples", done); }); it('should return 2 items', function(done) { search.find("Apples", function(err, res) { if (err) return done(err); res.should.have.length(2); done(); }); }); }); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 95

Slide 95 text

simplifyExecution

Slide 96

Slide 96 text

$  mocha   should be simplified to $  make  test and $  npm  test

Slide 97

Slide 97 text

./makefile # Makefile for sample module test: mocha --reporter spec --ui bdd .PHONY: test 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Slide 98

Slide 98 text

./makefile # Makefile for sample module test: mocha \ --reporter spec \ --ui bdd .PHONY: test 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Slide 99

Slide 99 text

$  make  test    Assertions        ✓  should  pass  on  truthiness          1)  should  fail  on  falsiness    ✖  1  of  2  tests  failed:    1)  Assertions  should  fail  on  falsiness:              AssertionError:  false  ==  true            at  (stack  trace  omitted  for  brevity) $  _

Slide 100

Slide 100 text

./package.json { "name": "sample", "version": "0.1.0", "scripts": { "test": "make test" } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Slide 101

Slide 101 text

$  npm  test    Assertions        ✓  should  pass  on  truthiness          1)  should  fail  on  falsiness    ✖  1  of  2  tests  failed:    1)  Assertions  should  fail  on  falsiness:              AssertionError:  false  ==  true            at  (stack  trace  omitted  for  brevity) $  _

Slide 102

Slide 102 text

eliminate global dependency $  npm  install  mocha  -­‐-­‐link

Slide 103

Slide 103 text

test: @./node_modules/.bin/mocha \ --reporter spec \ --ui bdd .PHONY: test 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 104

Slide 104 text

update dev dependencies $  npm  install  mocha  -­‐-­‐save-­‐dev $  npm  install  chai    -­‐-­‐save-­‐dev

Slide 105

Slide 105 text

$  npm  install  mocha  -­‐-­‐save-­‐dev $  npm  install  chai    -­‐-­‐save-­‐dev $  git  diff  package.json   diff  -­‐-­‐git  a/package.json  b/package.json index  439cf44..3609bb9  100644 -­‐-­‐-­‐  a/package.json +++  b/package.json @@  -­‐1,5  +1,7  @@  {      "name":  "sample", -­‐    "version":  "0.1.0" +    "version":  "0.1.0", +    "devDependencies":  { +        "mocha":  "~1.9.0", +        "chai":  "~1.6.0" +    }  }

Slide 106

Slide 106 text

notificationSystems

Slide 107

Slide 107 text

mocha --watch continuousTesting -w or --watch

Slide 108

Slide 108 text

$  mocha  -­‐-­‐watch  ✔  5  tests  complete  (22ms)  ^  watching

Slide 109

Slide 109 text

Growl

Slide 110

Slide 110 text

mac: win: also: apple app store growlForWindows.com growlNotify

Slide 111

Slide 111 text

mocha --growl growlNotifications -G or --growl

Slide 112

Slide 112 text

⌘S

Slide 113

Slide 113 text

test: @./node_modules/.bin/mocha \ --reporter spec \ --ui bdd watch: @./node_modules/.bin/mocha \ --reporter min \ --ui bdd \ --growl \ --watch .PHONY: test watch 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 114

Slide 114 text

mockingObjects

Slide 115

Slide 115 text

JavaScript ships with a mocking framework ...it’s called JavaScript

Slide 116

Slide 116 text

var me = {firstName: 'Jay' , lastName: 'Harris' , getFullName: function() { return this.firstName + ' ' + this.lastName; }}; // Returns 'Jay Harris' me.getFullName(); me.getFullName = function() { return 'John Doe'; }; // Returns 'John Doe' me.getFullName(); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 117

Slide 117 text

nock HTTP Mocking Library

Slide 118

Slide 118 text

nock github: install: flatiron/nock npm install nock

Slide 119

Slide 119 text

var http = require('http'); var reqOptions = { host: 'api.twitter.com', path: '/1/statuses/user_timeline.json?' + 'screen_name=jayharris' }; // ... http.request(reqOptions, resCallback).end(); // Returns live Twitter data 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 120

Slide 120 text

var nock = require('nock'); var twitter = nock('http://api.twitter.com') .get('/1/statuses/user_timeline.json?'+ 'screen_name=jayharris') .reply(200, "This worked"); // Returns "This worked" http.request(reqOptions, resCallback).end(); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 121

Slide 121 text

// Returns live Twitter data http.request(reqOptions, resCallback).end(); var nock = require('nock'); var twitter = nock('http://api.twitter.com') .get('/1/statuses/user_timeline.json?'+ 'screen_name=jayharris') .reply(200, "This worked"); // Returns "This worked" http.request(reqOptions, resCallback).end(); // Returns live Twitter data http.request(reqOptions, resCallback).end(); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 122

Slide 122 text

nock nock.recorder.rec(  ); nock.recorder.play(  );

Slide 123

Slide 123 text

Spies, Stubs, & Mocks Sinon.js

Slide 124

Slide 124 text

github: install: cjohansen/Sinon.JS npm install sinon Sinon.js

Slide 125

Slide 125 text

versionTesting

Slide 126

Slide 126 text

nvm Node Version Manager

Slide 127

Slide 127 text

nvm github: github: creationix/nvm hakobera/nvmw

Slide 128

Slide 128 text

$  nvm  list        v0.4.0        v0.6.18        v0.8.21        v0.4.7          v0.8.1        v0.10.0        v0.6.0          v0.8.8 current:     v0.8.1 10  -­‐>  0.10.0  (-­‐>  v0.10.0) 4  -­‐>  0.4.7  (-­‐>  v0.4.7) 6  -­‐>  0.6.18  (-­‐>  v0.6.18) 8  -­‐>  0.8.21  (-­‐>  v0.8.21) default  -­‐>  0.10.0  (-­‐>  v0.10.0) newest  -­‐>  0.10.0  (-­‐>  v0.10.0) $  _

Slide 129

Slide 129 text

$  node  -­‐-­‐version v0.10.0 $  nvm  install  v0.10.6 Now  using  node  v0.10.6 /Users/jayharris/.nvm/v0.10.6/bin/npm $  node  -­‐-­‐version v0.10.6 $  _

Slide 130

Slide 130 text

packageDistribution

Slide 131

Slide 131 text

Package Manager

Slide 132

Slide 132 text

./.npmignore filePackaging

Slide 133

Slide 133 text

npm adduser userSetup

Slide 134

Slide 134 text

$  npm  adduser Username:  (jayharris)  jayharris Password: Email:  ([email protected])  _

Slide 135

Slide 135 text

$  npm  whoami jayharris $  _

Slide 136

Slide 136 text

npm publish packagePublish

Slide 137

Slide 137 text

{  name:  'morale',    description:  'Async  API  wrapper  for  Morale',    'dist-­‐tags':  {  latest:  '0.2.0'  },    versions:        [  '0.1.0',          '0.1.2',          '0.2.0'  ],    maintainers:  'jayharris  ',    time:        {  '0.1.0':  '2012-­‐01-­‐23T03:24:59.824Z',          '0.1.2':  '2012-­‐01-­‐25T23:20:52.927Z',          '0.2.0':  '2012-­‐08-­‐13T16:23:28.488Z'  },    author:  'Arana  Software  ',    repository:        {  type:  'git',          url:  'git://github.com/aranasoft/morale-­‐node.git'  },    users:  {  fgribreau:  true  },    version:  '0.2.0',

Slide 138

Slide 138 text

$  npm  publish npm  http  PUT  https://registry.npmjs.org/morale npm  http  409  https://registry.npmjs.org/morale npm  http  GET  https://registry.npmjs.org/morale npm  http  200  https://registry.npmjs.org/morale npm  http  PUT  https://registry.npmjs.org/morale/0.2.1/-­‐tag/latest npm  http  201  https://registry.npmjs.org/morale/0.2.1/-­‐tag/latest npm  http  GET  https://registry.npmjs.org/morale npm  http  200  https://registry.npmjs.org/morale npm  http  PUT  https://registry.npmjs.org/morale/-­‐/ morale-­‐0.2.1.tgz/-­‐rev/25-­‐c9bbf49ea0bd2a750e257153fab5794b npm  http  201  https://registry.npmjs.org/morale/-­‐/ morale-­‐0.2.1.tgz/-­‐rev/25-­‐c9bbf49ea0bd2a750e257153fab5794b +  [email protected] $  _

Slide 139

Slide 139 text

{  name:  'morale',    description:  'Async  API  wrapper  for  Morale',    'dist-­‐tags':  {  latest:  '0.2.1'  },    versions:        [  '0.1.0',          '0.1.2',          '0.2.0',          '0.2.1'  ],    maintainers:  'jayharris  ',    time:        {  '0.1.0':  '2012-­‐01-­‐23T03:24:59.824Z',          '0.1.2':  '2012-­‐01-­‐25T23:20:52.927Z',          '0.2.0':  '2012-­‐08-­‐13T16:23:28.488Z',          '0.2.1':  '2012-­‐08-­‐30T19:10:20.133Z'  },    author:  'Arana  Software  ',    repository:        {  type:  'git',          url:  'git://github.com/aranasoft/morale-­‐node.git'  },

Slide 140

Slide 140 text

{ "private": "true" } privatePackages

Slide 141

Slide 141 text

./package.json { "name": "Sample", "version": "0.1.0", "description": "This is a sample module", "main": "index.js", "scripts": { "test": "echo \"Error: no tests avail.\" && exit 1" }, "author": "Jay Harris", "license": "BSD", "private": "true" } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Slide 142

Slide 142 text

$  npm  publish npm  ERR!  Error:  This  package  has  been  marked  as  private npm  ERR!  Remove  the  'private'  field  from  the  package.json  to   publish  it. $  _

Slide 143

Slide 143 text

npm shrinkwrap versionLockdown

Slide 144

Slide 144 text

$  npm  shrinkwrap wrote  npm-­‐shrinkwrap.json $  _

Slide 145

Slide 145 text

{ "name": "morale", "version": "0.2.1", "dependencies": { "underscore": { "version": "1.3.3" }, "mocha": { "version": "1.3.0", "dependencies": { "commander": { "version": "0.6.1" }, "growl": { "version": "1.5.1" }, "jade": { "version": "0.26.3", 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

Slide 146

Slide 146 text

$  rm  npm-­‐shrinkwrap.json $  npm  update $  npm  test $  npm  shrinkwrap

Slide 147

Slide 147 text

tellEveryone

Slide 148

Slide 148 text

Go make some Awesome

Slide 149

Slide 149 text

jay harris P R E S I D E N T [email protected] #nodemoduledev @jayharris