Errata

Node for Front-End Developers

Errata for Node for Front-End Developers

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 2
top 2nd paragraph

at the top of chapter 1: Getting Node Set Up, page 2, where you say to use this command line to install the node package manager (npm) ?

$ curl http://npmjs.org/install.sh | sh

when you do that, as of today, 20-May-2014, you get the following error back from npmjs.org ?

$ curl http://npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 193 100 193 0 0 1431 0 --:--:-- --:--:-- --:--:-- 1440
sh: line 1: html: No such file or directory
sh: line 2: syntax error near unexpected token `<'
'h: line 2: `<head><title>301 Moved Permanently</title></head>

the correct command should be ?

$ curl -L http://npmjs.org/install.sh | sh

the "-L" is for location redirects, the directory for the tarball and install has moved, permanently, at npmjs.org. see ?

https://github.com/npm/npm/issues/1641 (look for final answer toward the bottom).

best,

? faddah wolf
portland, oregon, u.s.a.

Faddah Wolf  May 20, 2014 
PDF Page 11
1st full paragraph

static.js is said to be in node_modules/connect/middleware but is really located in node_modules/connect/lib/middleware

Tim Tyrrell  Feb 04, 2012 
PDF Page 14
United States

connect.router does not seem to be an existing method. Trying to run the code on page 14 gives the following error:

TypeError: Object function createServer() {
function app(req, res){ app.handle(req, res); }
utils.merge(app, proto);
utils.merge(app, EventEmitter.prototype);
app.route = '/';
app.stack = [];
for (var i = 0; i < arguments.length; ++i) {
app.use(arguments[i]);
}
return app;
} has no method 'route'
at Object.<anonymous> (/Users/jason/Code/personal/node/test/app.js:5:11)
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:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Jason Schock  Nov 05, 2012 
PDF Page 16
error in code connect.static(__dirname + "/public"),

error with code connect.static(__dirname + "/public"),

solution:
var connect = require("connect");

var app = connect()
.use(connect.static(__dirname + '/public'))
.use(connect.bodyParser())
.use(function(req, res) {
var userName = req.body.firstName + " " + req.body.lastName,
html = "<!doctype html>" +
"<html><head><title>Hello " + userName + "</title></head>" +
"<body><h1>Hello, " + userName + "!</h1></body></html>";

res.end(html);
})
.listen(8000);

Fabian Niederer  Mar 12, 2012 
PDF Page 19
connect(connect.static(__dirname + "/public")).listen(8000);

03-07.js gives an error: "Cannot GET /"

code line: connect(connect.static(__dirname + "/public")).listen(8000);

solution:
var connect = require("connect");

var app = connect().use(connect.static(__dirname + '/public'));

// create socket.io server on port 1337
io = require("socket.io").listen(1337);

app.listen(8000);

// listen for connection from an individual client
io.sockets.on("connection",
function(socket) {
// listen for setName event
socket.on("setName",
function(data) {
var userName = data.firstName + " " + data.lastName; // publish nameSet event with new username
socket.emit("nameSet", {
userName: userName
});
});
});


source: http://stackoverflow.com/questions/9627441/cannot-get-with-connect-on-node-js

fabich  Mar 12, 2012 
PDF Page 19
error in code

error with code line connect(connect.static(__dirname + "/public")).listen(8000);

solution:
var connect = require("connect");

var app = connect().use(connect.static(__dirname + '/public'));

// create socket.io server on port 1337
io = require("socket.io").listen(1337);

app.listen(8000);

// listen for connection from an individual client
io.sockets.on("connection",
function(socket) {
// listen for setName event
socket.on("setName",
function(data) {
var userName = data.firstName + " " + data.lastName; // publish nameSet event with new username
socket.emit("nameSet", {
userName: userName
});
});
});

Fabian Niederer  Mar 12, 2012 
Printed Page 40
1st code sample

Strange wrapping behavior: 'document.getElementById("hdnId").value;' is left-aligned whereas it should be indented from the previous line.

Michael Bolin
Michael Bolin
 
May 01, 2012 
Printed Page 43
code sample

The code sample has the line:

ns.modul = function() {

I am not certain, but should this be:

ns.module = function() {

If not, an inline comment explaining the funny spelling would help.

Michael Bolin
Michael Bolin
 
May 01, 2012 
ePub Page 222
code listing for app.js, line 20

code listing says

path.exists(localPath, function (exists) {

There is no such function in the path module. It should be "fs".

fs.exists(localPath, function (exists) {

pointmatic  Jul 19, 2015