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});
socket.sendMessage(message.serialize());
});
this.chatList.init();
});

1 Like

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.
(C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:304:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.
(C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\npm-
lifecycle\lib\spawn.js:55:14)
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?