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.

6516 (2) [Avatar] Offline

I'm keen to read about Angular2 and I wanted to follow along the book.
I checked out chapter2 nmp installed and did gulp go. This all works fine.

After that I wanted to change to step1 as mentioned in the book by issueing this command:

git checkout -f step1

This results in an error, because step1 does not (yet) exist.

Please either fix the github repository or change the text in the book.

Best regards,
Andreas Kroll
jeremy.wilken (208) [Avatar] Offline
Hi Andreas,

I just pushed up the git tags, I had them locally but hadn't pushed them. My apologies, and let us know if that gets you going!

Thanks for picking up the book, I hope you will enjoy it.

6516 (2) [Avatar] Offline
Hi again,

thanks for the quick answer.
I just tried the command again and now it is working perfectly.
Thanks for that.

Best regards,
Andreas Kroll
384575 (1) [Avatar] Offline
[ 160 KB ]

I'm able to check out all the steps, but other than step 1 and the master branch, I haven't been able to get the code to work. I keep getting these errors in the console (see attachment). I've also tried copying the code straight from the book, and I get the same errors.

jeremy.wilken (208) [Avatar] Offline
If you inspect the files, you'll see they are returning back the index.html file contents. It would appear you've got something strange happening and those files aren't found where they should be. If you can get the master branch to work, then that is the important one that has everything.

I'd need a little more information, or even better can you zip up your project folder while it is failing so I can inspect it?

The good news is the tooling has been getting simpler from Angular, but this repo hasn't been updated to use it yet.
sguillory6 (28) [Avatar] Offline

I am seeing basically the same thing. After the chapter two additions to the tag step1, all of the files that the browser wants to load aren't where they are expected to be. The odd thing is that the web server that gulp go starts up has the following behavior in this project: if you request an non-existent file, it doesn't return a 404 but rather the index.html file.

I have done a lot of tinkering to get a little further along, but basically the step1 tagged code just doesn't work.
jeremy.wilken (208) [Avatar] Offline
Have you stopped and restarted the local server after you checkout the new files? You can see the files are located in the git repo
sguillory6 (28) [Avatar] Offline
I stand corrected. After cloning the repo and checking out the step1 tag, the app does display as shown in figure 2.4 on page 31. However, after performing the steps in sections 2.3.1, 2.3.2 and 2.3.3, and running the app, the app errors out, apparently due to a typo in the gulpfile.js. I had to make the following change to the gulpfile.js to get the app to display like figure 2.5 on page 34:

var PATHS = {
lib: [
- 'node_modules/angular2/node_modules/rx/dist/rx.js',
+ 'node_modules/angular2/angular2.js',
+ 'node_modules/rx/dist/rx.js',

In addition, if you just do a "git checkout -f step2" and run "gulp go", you just get an error starting the server:

poirot:chapter2 kmorris$ git status
HEAD detached at step2
Untracked files:
(use "git add <file>..." to include in what will be committed)


nothing added to commit but untracked files present (use "git add" to track)
poirot:chapter2 kmorris$ gulp go
throw err;

Error: Cannot find module 'tsd'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/Users/kmorris/Development/angular2-in-action/chapter2/gulpfile.js:10:11)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
jeremy.wilken (208) [Avatar] Offline
When the command line says it cannot find a module, you should run `npm install` again. Sometimes it doesn't install everything, or other things can happen that reinstalling can fix.
jeremy.wilken (208) [Avatar] Offline
I just realized, this might be due to npm 3 changes in the way modules are installed. Run `npm install tsd` to get this module, I bet if you are on Node 4+ that the npm changes might not be installing all child dependencies (crazy right?). If it says any other module is not installed, you'll need to `npm install ___` each of them by name as well.

I am planning to make all of this work on Node 4+ only, so this shouldn't be an issue when that gets updated.
Steve V (3) [Avatar] Offline
I'm using version 4 of the Meap and I'm getting same errors as the other guy
all referring to Rx.js
Actually, the other guy was right in the gulp file the path to rx.js was:

After locating the rx.js I got rid of "node_modules/angular2" part of the path and the page loaded properly.
Do you you know why gulp got it wrong?
Steve V (3) [Avatar] Offline
Steve V wrote:I'm using version 4 of the Meap and I'm getting same errors as the other guy
all referring to Rx.js
Actually, the other guy was right in the gulp file the path to rx.js was:

After locating the rx.js I got rid of "node_modules/angular2" part of the path and the page loaded properly.
Gulp got it wrong because the file I downloaded from GITHUB was wrong !

jeremy.wilken (208) [Avatar] Offline
The Gulp build may be wrong depending on which version of Node you are using. The way files get installed changed somewhere between Node versions (technically NPM versions) and so this can occur on newer Node versions that I haven't used. So your fix is good for the moment, and when I get the chapter updated the Gulp build will be removed for a simpler approach.
434910 (3) [Avatar] Offline
just got working with Chapter 2: git checkout -f step1, and followed along with the book to get to step2, but my edits failed to run.

So i just tried to go with the git checkout -f step2, and it gets farther along, however still fails to load the page.

it does say this when i am running gulp go: path not in index, attempt-adding: angular2/angular2.d.ts

ill try to figure that out.
jeremy.wilken (208) [Avatar] Offline
There should be an update to this MEAP any day now that fixes this issue. It uses the CLI instead so things are a bit easier to manage.