The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Thank you very much!
First of all, thanks for the update of chapters 11 and 12.

The matter is that I can't see the code in the GitHub repository. Is Simon's repository going to be updated or is a new one being used?

Thanks again for the update. The book is looking absolutely great smilie
I think he did it because it was easier to understand how promise (single event) works, and then use that knowledge to move to into use of observables (Stream).
First of all, thank you very much Simon. I enjoyed a lot the 1st edition of your book and this 2nd edition is also amazing. I think it's the best way to start with MEAN. I'm recommending your book to all my friends trying to tame this technology.

I just want to make you aware of a small mistake in the chapter 10.2.1. In the page 357 of the 01/01/2018 version it says a new public member newReview in location-details.component.html. It should be in the location-details.component.ts instead. It's a minor thing and anyone following the book will probably notice the mistake quite quickly.

Again, thank you very much for your book!

Edit: I also found that in the same edition, in page 357, the code:
<input [(ngModel)]="" id="name" name="name" required="required"

should be:
<input [(ngModel)]="" id="author" name="author" required="required"
I'm stuck in Chapter 8, particularly in the data services. The code compiles just fine, but nothing appears in the browser. I added the code for allowing CORS requests in express, but the problem persists. Checking the console of the browser, I can see the following error:

HomeListComponent_Host.ngfactory.js? [sm]:1 ERROR Error: StaticInjectorError(AppModule)[Loc8rDataService -> Http]: 
  StaticInjectorError(Platform: core)[Loc8rDataService -> Http]: 
    NullInjectorError: No provider for Http!
    at _NullInjector.get (core.js:994)
    at resolveToken (core.js:1292)
    at tryResolveToken (core.js:1234)
    at StaticInjector.get (core.js:1102)
    at resolveToken (core.js:1292)
    at tryResolveToken (core.js:1234)
    at StaticInjector.get (core.js:1102)
    at resolveNgModuleDep (core.js:10837)
    at NgModuleRef_.get (core.js:12070)
    at resolveDep (core.js:12560)

I can't go any further than page 296 with this problem... I appreciate any help.

Edit (solved):

Just edited app.module.ts and added the following:

- At the top, with the imports:
import { HttpModule } from '@angular/http';

- The imports under @NgModule needed the following:
 imports: [

You need to install Angular cli (see appendix A.4) and then create the Angular boilerplate (see Chapter 8.1.1).
Have you used Brew for installing Node?

I was also having problems and I fixed them using this:
cd public_app
rm -rf node_modules
rm package-lock.json
npm install --only=dev
pog22 wrote:Chapter 3 of the 1st edition contains the following:

In app.js find the following lines:

var routes = require('./routes/index');
var users = require('./routes/users');

and change them to the following (modifications in bold):

var routes = require('./app_server/routes/index');
var users = require('./app_server/routes/users');

However the lines it mentions don't exist. I even tried uninstalling express and installing v4.9 (used in the book) but to no avail. Can someone from Manning help?

Dude, this forum is for the 2nd edition... Anyways, check the following:

- Did you do a npm install?
- Does the folder app_server/routes exists?
- Does that folder contains the files index.js and routes.js?
I'm struggling to connect to MongoDB using mongoose. The matter is that, if I use mongoose 5, I have problems with geonear. But If I use mongoose 4.9.1, I can connect to Mongo using Linux but not using OS X. When I try to use mongoose 4.9.1 in OS X, I always have the same error:

Mongoose disconnected
Mongoose connection error: { MongoError: failed to connect to server [undefined:27017] on first connect [MongoError: getaddrinfo ENOTFOUND undefined undefined:27017]

Any suggestion?

EDIT: It seems like in OS X the Node environment is set as production by default (NODE_ENV === 'production'), and therefore taking the wrong settings... I just need to start nodemon as:
NODE_ENV=development nodemon
Ok, it seems like the cause is mongoose's version. Using "mongoose": "^4.9.1" instead of "mongoose": "^5.0.1" (which is installed by default with Express at the moment of writing this) in package.json seems to solve the problem. I guess in the new version of mongoose geonear is used in a different way...

I'm having a problem in chapter 7. I'm even using the files from GitHub but the problem persists. When I open the home page, where all the locations should be listed, I have the API lookup error instead. Displaying in console the data causing the error 500, I get this:

GET /api/locations?lng=-0.7992599&lat=51.378091&maxDistance=20 500 172.504 ms - 3312
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width, initial-scale=1.0"><title></title><link rel="stylesheet" href="/stylesheets/bootstrap.min.css"><link rel="stylesheet" href="/stylesheets/font-awesome.min.css"><link rel="stylesheet" href="/stylesheets/tether.min.css"><link rel="stylesheet" href="/stylesheets/style.css"></head><body><nav class="navbar navbar-expand-lg navbar-dark bg-dark"><a class="navbar-brand" href="/">Loc8r</a><div class="container"><button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><div class="collapse navbar-collapse" id="navbarColor02"><ul class="navbar-nav mr-auto"><li class="nav-item active"><a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a></li><li class="nav-item"><a class="nav-link" href="/about/">About</a></li></ul></div></div></nav><div class="container"><h1>Loc.geoNear is not a function</h1><h2></h2><pre>TypeError: Loc.geoNear is not a function

Therefore, the cause is something with geoNear. I spent hours and hours trying to sort this problem, but I only managed to have a huge headache. Does anyone has any idea what can be failing? I'm sure that the cause it's something simple and evident, but I can't find it.

Thanks for your help.