I have copied the code from page 53 as follows:
Code JavaScript:var dnode = require('dnode'); dnode(function(remote, conn) { this.auth = function(user, pass, cb) { var users = { foo: 'bar' }; var p = users[user]; if (p === pass) cb(null, 'AUTHORIZED!'); else cb('REMOTE ACCESS DENIED'); }; }).listen(process.argv[2]);
When I run the code as instructed node auth 8090 I get the following error
events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:769:11)
at Server._listen2 (net.js:909:14)
at listen (net.js:936:10)
at Server.listen (net.js:985:5)
at D.dnode.listen (/Users/test/node_projects/chapter03/node_modules/dnode/index.js:112:16)
at Object.<anonymous> (/Users/test/node_projects/chapter03/dnode/auth.js:11:4)
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)
What am I doing wrong?
>> I restarted terminal and this code is now working.


Reply With Quote

Bookmarks