shyamseshadri / angularjs-book

Examples and Code snippets from the first AngularJS O'Reilly book which is now heavily out of date!
1.63k stars 1.11k forks source link

Downloaded the code in Chapter 4 - get 404 error #3

Closed rhbgames closed 11 years ago

rhbgames commented 11 years ago

When I go to http://localhost:9000/, I see Loading.... New Recipe Recipe List In the console there is the error Failed to load resource: the server responded with a status of 404 (Not Found)

I click on New Recipe and am able to fill out the form, but when I click on Save, I get: POST http://localhost:9000/recipes 404 (Not Found)

Stack trace is below if that is meaningful to you.... would love to run this sample app - seems pretty important in understanding Angular.

Thanks in advance for any advice... RB


GET http://localhost:9000/recipes 404 (Not Found) angular.min.js:96 (anonymous function) angular.min.js:96 o angular.min.js:93 l angular.min.js:92 g.(anonymous function) angular-resource.min.js:8 (anonymous function) services.js:15 $routeProvider.when.resolve.recipes controllers.js:12 d angular.min.js:26 (anonymous function) angular.min.js:79 m angular.min.js:6 e.when.then.then.b.locals angular.min.js:79 i angular.min.js:75 i angular.min.js:75 (anonymous function) angular.min.js:76 e.$eval angular.min.js:86 e.$digest angular.min.js:84 e.$apply angular.min.js:86 (anonymous function) angular.min.js:15 d angular.min.js:26 qb angular.min.js:15 jc angular.min.js:15 (anonymous function) angular.min.js:159 a angular.min.js:114 (anonymous function) angular.min.js:22 m angular.min.js:6 c

shyamseshadri commented 11 years ago

Hi,

Did you start the server by running

node web-server.js

from the chapter4/guthub folder?

You might need to install your dependencies first with (npm install -d) again from the same folder.

Please let me know if that works.

rhbgames commented 11 years ago

That was precisely the problem. I had originally set up the project with yeoman, so I was running "grunt server" to start the server.

For anyone else that has this problem, when I tried "node web-server.js" I got Error: Cannot find module 'express'. I then ran "npm install -d" (which didn't seem to point out any errors - but I may not have been doing it correctly). "npm install express" solved the problem, then "node web-server.js" worked and then the sample code ran just fine.

Thanks SO MUCH for the super quick response!