Errata

Learning Node

Errata for Learning Node

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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

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

Version Location Description Submitted By Date submitted Date corrected
Better Callback Management with Async (Chapter 3)

First paragraph after Example 3-6: fs.stats method should be fs.stat method.

Note from the Author or Editor:
Corrected in text in Ajax

David Powers  Jul 27, 2016 
ePub
Sample chap6-5.js

Line #5 in chap6-5.js iis

fs.open('./new.txt','a+',0x666, function(err, fd) {

This does not set new.txt's file permissions to -rw-rw-rw- on my Mac (10.0.5 running Node 7), but to ---xr--r--.

In my environment, the permission is also affected by the user's umask, which is 0022. In this case,

fs.open('./new.txt','a+',0o666, function(err, fd) {

sets a file permission of -rw-r--r--. To get -rw-rw-rw-, the example must first set the process umask:

process.umask(0o000);
fs.open('./new.txt','a+',0o666, function(err, fd) {

Note from the Author or Editor:
A note about umask has been added to the text, corrected in Ajax.

"Optionally, following the action flag you can specify a mode value, which is applied if the file is created. By default, this value is 0o666 , which is readable and writeable. Just be aware that on some systems, such as the Mac, the user's umask can impact on this mode. You can change the umask value using process.umask() ."

Thad Humphries  Nov 01, 2016 
PDF
Page 36
Creating an Asynchronous Callback Function

The description doesn't match the example code. Text states that the function takes three arguments, with the second being a string. Code takes two arguments, with no string and no check for a string. Code works as described otherwise.

Note from the Author or Editor:
You are correct, it's been corrected to read

The function takes two arguments: the first is a number and the second is the callback function. In doSomething() , if the first argument is not a number (or missing) the function creates a new Error object, which gets returned in the callback function. If no error occurs, the callback function is called, the error is set to null, and the function data is processed, and the generated value returned.

Leslie Johnson  Jul 24, 2016 
ePub
Page 36
text -> If you change the value of number to 10

In the following text:
If you change the value of number to 10, the application prints the following to the console:


The value of number variable is already 10. Maybe author meant '10'?

Note from the Author or Editor:
You are correct.

The section should be adjusted to read (and has been correct in Atlas).

The function takes two arguments: the first is a number and the second is the callback function. In doSomething(), if the first argument is not a number (or missing) and the second argument is not a function (or missing) the function creates a new Error object, which gets returned in the callback function. If no error occurs, the callback function is called, the error is set to null, and the function data is processed, and the generated value returned.

Hovik Manvelyan  Sep 15, 2016 
Printed
Page 36-38
Example2-5 and explanation

- p36 text: " ...Node application that creates an object with one function... " I took this to mean that the object was created by using one function (only). :)

- p36 text: Function doSomething seems to take two arguments (a number and a function), not three. I don't understand the text at all.

- code: There is no reason to check if callback_ is a 'function' since no code depends on it being a function. If it is not a function, the script crashes anyway.

- code: fibonaCCi has two c's usually :)

- p38 text: The value of 'number' is already 10, and the script works fine. You get the error message (and possible system error messages) if the variable 'number' is not a number. As noted, if you use 50, as the number, you'll wait a while.

Note from the Author or Editor:
Yes, this is correct. I have made the correction in Atlas.

The section should be adjusted to read

The function takes two arguments: the first is a number and the second is the callback function. In doSomething() , if the first argument is not a number (or missing) the function creates a new Error object, which gets returned in the callback function. If no error occurs, the callback function is called, the error is set to null, and the function data is processed, and the generated value returned.

Trekker Dave  Apr 21, 2017 
PDF
Page 37
Top of page.

The code of Example 2-5 demonstrates the process.nextTick() function. The printing of this function is indented as if it was part of the previous if-statement body. Since it is separate, it should aligned with the preceding if statement.

Note from the Author or Editor:
Fixed directly in book (Atlas)

Paul Glezen  Dec 12, 2016 
PDF
Page 39
Last code sample on page.

en.emit should be em.emit.

Note from the Author or Editor:
Fixed directly in book (Atlas)

Paul Glezen  Dec 13, 2016 
PDF
Page 58
Near the top

The top of this PDF page lists steps the "require" module uses to find modules. The 4th step is to search modules installed globally. It seems this is changing. I attempted to install express globally. But "require" couldn't find it. The following Stack Overflow discussion goes into this more deeply and provides other references.

http://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package

Basically you can populate the NODE_PATH variable or create symlinks to the global version. But without this, non-core modules will not be found in the global location.

Note from the Author or Editor:
Fixed directly in book (Atlas).

Paul Glezen  Dec 28, 2016 
PDF
Page 88
Middle of page.

It seems the behavior of REPL with respect to the underscore has changed. If you assign to the underscore, the underscore no longer takes on the value of the last expression. REPL now warns of this. So the example with incrementing _ and then having it take on the value of the new list no longer applies.

The warning REPL provides is:

Expression assignment to _ now disabled.

This is discussed in the developer issue list here: https://github.com/nodejs/node/issues/5431.

Note from the Author or Editor:
Fix in book (Atlas)

Paul Glezen  Dec 23, 2016 
PDF
Page 112
code

in the book:
console.log('server listening on 8214');

should be:
console.log('server listening on 8124');

Note from the Author or Editor:
Modify code to display 8124

jpsalvadorm  Jun 22, 2016 
Printed
Page 137
Top of page

It is: fs.readFile('./some.txt', 'utf-8', function(data, err) {
should be: fs.readFile('./some.txt', 'utf-8', function(err, data) {

Note from the Author or Editor:
You're absolutely correct. Fixed in the book. Should read.

var fs = require('fs');

fs.writeFile('./some.txt','Writing to a file',function(err) {
if (err) return console.error(err);
fs.readFile('./some.txt','utf-8', function(err, data) {
if (err) return console.error(err);
console.log(data);
});
});

Jerzy Wobalis  May 21, 2017