Errata: 1st Edition


Best way to add headers to the json-api adapter? Chapter 22, page 412


Chapter 18, (sorry, I’m on Kindle, can’t tell the page number)
And moments after adding:

import moment from ‘moment’;

you need to use the new init() function you created, I did in the registerOpenHandler in the ChatApp:

socket.registerOpenHandler(() => {
this.chatForm.init((data) => {
let message = new ChatMessage({message: data});


In chapter 17 on page 332, the npm run build command is throwing errors.
Here is my debug log:
0 info it worked if it ends with ok
1 verbose cli [ ‘C:\Program Files\nodejs\node.exe’,
1 verbose cli ‘C:\Users\user\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js’,
1 verbose cli ‘run’,
1 verbose cli ‘build’ ]
2 info using npm@6.1.0
3 info using node@v10.5.0
4 verbose run-script [ ‘prebuild’, ‘build’, ‘postbuild’ ]
5 info lifecycle chattrbox@1.0.0~prebuild: chattrbox@1.0.0
6 info lifecycle chattrbox@1.0.0~build: chattrbox@1.0.0
7 verbose lifecycle chattrbox@1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle chattrbox@1.0.0~build: PATH: ‘…’
9 verbose lifecycle chattrbox@1.0.0~build: CWD: C:\Users\enjoi\Documents\projects\chattrbox
10 silly lifecycle chattrbox@1.0.0~build: Args: [ ‘/d /s /c’,
10 silly lifecycle ‘browserify -d app/scripts/src/main.js -o app/scripts/dist/main.js’ ]
11 silly lifecycle chattrbox@1.0.0~build: Returned: code: 1 signal: null
12 info lifecycle chattrbox@1.0.0~build: Failed to exec build script
13 verbose stack Error: chattrbox@1.0.0 build: browserify -d app/scripts/src/main.js -o app/scripts/dist/main.js
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:961:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
14 verbose pkgid chattrbox@1.0.0
15 verbose cwd C:\Users\user\Documents\projects\chattrbox
16 verbose Windows_NT 10.0.17134
17 verbose argv “C:\Program Files\nodejs\node.exe”
“C:\Users\user\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js” “run” “build”
18 verbose node v10.5.0
19 verbose npm v6.1.0
20 error code ELIFECYCLE
21 error errno 1
22 error chattrbox@1.0.0 build: browserify -d app/scripts/src/main.js -o app/scripts/dist/main.js
22 error Exit status 1
23 error Failed at the chattrbox@1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I went back to make sure all my syntax from this chapter is correct and updated according to the errata. Explicitly, the problem is the export statement in app.js. It appears the parser isn’t recognizing the sourcetype to be of ‘module’.

I looked for some solutions online, and it seems that an update to browserify has made the code non-functional. Perhaps it would have been smart to specify version numbers during the npm installations?