1

I'm trying to learn Angular.js and I'm trying to setup my development environment (as described in Pro Angularjs) and I'm having problems. Others have experienced similar problems but even after looking at some of the solutions I still can't get mine to work. Since I'm new to all this it's probably something very basic and your help is appreciated.

My setup is:

In my "nodejs" directory I have a directory called "angularjs" and a file called "server.js" whose contents are shown below:

var connect = require('connect'),
    serveStatic = require('serve-static');

var app = connect();

app.use(serveStatic("/angularjs"));
app.listen(5000);

In my "angularjs" folder I have a file called "test.html" with contents:

    <!DOCTYPE html>
<html ng-app>
<head>
    <title>First Test</title>
    <script src="angular.js"></script>
    <link href="bootstrap.css" rel="stylesheet" />
    <link href="bootstrap-theme.css" rel="stylesheet" />
</head>
<body>
    <div class="btn btn-default">{{"AngularJS"}}</div>
    <div class="btn btn-success">Bootstrap</div>
</body>
</html>

When I run it I get "Cannot GET /test.html". Any help is appeciated.

Thanks,

Pete

1
  • Try renaming it to 'index.html' instead of 'test.html'. Commented Jan 8, 2015 at 18:45

1 Answer 1

2

Try

app.use(serveStatic("./angularjs"));
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks yzarubin. I actually thought I tried that but apparently not. Everything is working now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.