deeleman / learning-angular2

Code samples repository for the examples provided in "Learning Angular 2", published by Packt Publishing - THE BOOK COVERS UP TO RC.1 and hence is severely OUTDATED. PLEASE REFER TO THE LATEST EDITIONS INSTEAD.
https://www.packtpub.com/web-development/learning-angular-2
108 stars 59 forks source link

Chapter 9 example won't run #40

Closed carho closed 8 years ago

carho commented 8 years ago

I am a customer from Packt. I bought the book just 3 days ago. I read the book on the weekend:-) Testing out the example in chapter 1 goes well. Because i test on Windows:-( i had to tweek the package.json file (rm does not funktion on windows) So i replaces this command with

if exist build rmdir /S /Q  built

Playing around with the result leads to mysterious errors. So i decided to try out Chapter 9 After replacing the 'rm' command an

npm install

does succed. an

npm start

gives wired errors for me: (BTW this is the same kind of error, i got when expanding the example from chapter 1)

D:\work\ANGULAR2\chapter_09>npm start

> chapter_09@1.0.0 prestart D:\work\ANGULAR2\chapter_09
> tsc

> chapter_09@1.0.0 start D:\work\ANGULAR2\chapter_09
> concurrently "npm run tsc:w" "npm run lite"

[1]
[1] > chapter_09@1.0.0 lite D:\work\ANGULAR2\chapter_09
[1] > lite-server
[1]
[0]
[0] > chapter_09@1.0.0 tsc:w D:\work\ANGULAR2\chapter_09
[0] > tsc -w
[0]
[1] Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
[1] ** browser-sync config **
[1] { injectChanges: false,
[1]   files: [ './**/*.{html,htm,css,js}' ],
[1]   watchOptions: { ignored: 'node_modules' },
[1]   server: { baseDir: './', middleware: [ [Function], [Function] ] } }
[0] 08:33:58 - Compilation complete. Watching for file changes.
[0] events.js:160
[0]       throw er; // Unhandled 'error' event
[0]       ^
[0]
[0] Error: Error watching file for changes: UNKNOWN
[0]     at exports._errnoException (util.js:1026:11)
[0]     at FSEvent.FSWatcher._handle.onchange (fs.js:1406:11)
[0]
[0] npm
[0]  ERR! Windows_NT 6.3.9600
[0] npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "tsc:w"
[0] npm ERR! node v6.4.0
[0] npm ERR! npm  v3.10.3
[0] npm ERR! code ELIFECYCLE
[0] npm ERR! chapter_09@1.0.0 tsc:w: `tsc -w`
[0] npm ERR!
[0]  Exit status 1
[0] npm ERR!
[0] npm ERR! Failed at the chapter_09@1.0.0 tsc:w script 'tsc -w'.
[0] npm ERR! Make sure you have the latest version of node.js and npm installed.
[0] npm ERR! If you do, this is most likely a problem with the chapter_09 package,
[0] npm ERR! not with npm itself.

I thought, that after installing this examples all dependencies get installed in the right version. But perhaps this is not the case. For me it will be sufficient if someone can explain to me what this error means. And even better, a way to avoid this kind of error.

For now, this problem does not hinder me in learning angular2. The book is a wonderful reference material. And i am used to the fact, that early examples do not functioning. (JSF, Play, Richfaces suffered all from this problem)

What i am doing now, is to get an working example from PrimeNG and with the help from the book understand its structure. Update: Please have at look at this: google groups entry

deeleman commented 8 years ago

First of all, I'm sorry to learn that you're facing these issues and apologies for the late reply.

I've carefully read the information posted on your message and after reading the thread live at Google Groups I can only conclude that we might be facing an issue probably caused by concurrently not playing well with lite-server.

As a possible workaround (I haven't been able to replicate the issue on either Mac or Linux) I would suggest to upgrade both lite-server and concurrently to its latest versions. To do so just remove both dependency lines from the devDependencies block at package.json and install the latest versions by running the following on the console:

$ npm install concurrently lite-server --save dev

This will install v.2.2 versions for both packages. Try running npm start again and see what happens.

Should this does not solve the issue for you, perhaps you will want to skim the dev process a bit by removing the server instantiation from the npm start command. In that cause, just replace the start command payload to the following:

"start": "tsc:w",

Basically we're ditching the use of concurrently from the mix. Then instantiate the dev web server on a separate command, pointing to the working directory. You can either try run lite-server on a separate thread r either just install and run your own instance of BrowserSync.

Sorry in advance for not providing a more appropriate patch.

deeleman commented 8 years ago

Is this issue still on? Please let me know so we can provide further support or close the issue otherwise. Thanks.

carho commented 8 years ago

Thanks for your answer. Now, i must apologize for my late response. Yes, it is a problem with windows. concurrently does not work well on this 'os'.

The only workaround is to not use windows:-) This kind of error does occur on linux too, but the needed size of the application is much bigger than on windows. As you wrote: ditching 'concurrently' seems to be the only solution. At least for a project called 'Learning ..' Your book is great, and is easy to understand. But some features of the windows operating system does not allow to use 'concurrently' With your advice (not using concurrently) i have a running projhect now, thanks a lot Ciao

Am 05.09.2016 00:42, schrieb Pablo Deeleman:

First of all, I'm sorry to learn that you're facing these issues and apologies for the late reply.

I've carefully read the information posted on your message and after reading the thread live at Google Groups I can only conclude that we might be facing an issue probably caused by |concurrently| not playing well with |lite-server|.

As a possible workaround (I haven't been able to replicate the issue on either Mac or Linux) I would suggest to upgrade both |lite-server| and |concurrently| to its latest versions. To do so just remove both dependency lines from the |devDependencies| block at |package.json| and install the latest versions by running the following on the console:

$ npm install concurrently lite-server --save dev```

This will install v.2.2 versionsfor both packages. Try runningnpm start again and see what happens.

Should this does not solve the issuefor you, perhaps you will want to skim the dev process a bit by removing the server instantiation from thenpm start command. In that cause, just replace thestart command payload to the following:

"start":"tsc:w",

Basically we're ditching the use of concurrently from the mix. Then instantiate the dev web server on a separate command, pointing to the working directory. You can either try run lite-server on a separate thread r either just install and run your own instance of BrowserSync.

Sorry in advance for not providing a more confident patch.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/deeleman/learning-angular2/issues/40#issuecomment-244632848, or mute the thread https://github.com/notifications/unsubscribe-auth/AQUPQq5FTSFWGH5ED-AXs3LoSIaUe2KSks5qm0logaJpZM4JwM_d.

deeleman commented 8 years ago

I'm really sorry about this issue, and thank you so much for your kind words.