Reputation: 1757
I am beginning to read Pro AngularJS. In the section to setup the development environment it has me create a angularjs directory and put a test.html file into it. Outside of that folder I installed 'connect' and 'serve-static' for Node.js. I also created a server.js file. The contents are seen below:
var connect = require('connect');
var app = connect().use(connect.static('/angularjs'));
app.listen(5000);
When visiting the following URL http://localhost:5000/test.html
all I see is the text "Cannot GET /test.html".
I have looked at this and this question here on SO. None of the solutions were helpful for me.
Upvotes: 8
Views: 7175
Reputation: 63
instead of var app = connect().use(connect.static('/angularjs'));
use
var app = connect().use(connect.static('./angularjs'));
its worked for me
Upvotes: 0
Reputation: 1
Below worked out for me.
var connect=require('connect'),
serveStatic=require('serve-static');
var path = require('path');
var server=connect();
server.use(serveStatic(path.resolve(__dirname, '..', 'angularjs')));
server.listen(5000);
Upvotes: -2
Reputation: 1757
The book didn't really do a good job of describing where to put server.js that I remember. So I had it one folder above the angularjs folder. Therefore, the '..' needed to be removed. I made the mistake of leaving in the '/' which caused my problems. Just as I figured ... a stupid small mistake (hardest to find).
Upvotes: 9
Reputation: 66
First, make sure your ../angularjs
folder contains test.html
file?
Then, you can try to resolve path
var connect = require('connect');
var path = require('path');
var app = connect().use(connect.static(path.resolve(__dirname, '..', 'angularjs')));
app.listen(5000);
Upvotes: 1