0

When I ran node to set up a web server, I got the following error:

 C:\Users\Me\server.js:4
   connect.static("../angularjs")
                 ^
TypeError: undefined is not a function
    at Object.(anonymous) (C:\Users\Me\server.js:4:19)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129.160
    at node.js:814:3

This is the contents of server.js

 var connect = require('connect');

 connect.createServer(
     connect.static("../angularjs")

 ).listen(5000);

I'm following instructions in Pro AngularJS book from Apress by Adam Freeman.

I downloaded the listings from their website.

I'm running Windows 7 Pro

I tried the solution suggested to install serve-static module and now when I run the revised server.js the command window just hangs.

The new server.js is:

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

var app = connect();

app.use(serveStatic("../angularjs"));
app.listen(5000);
ChuckO
  • 2,543
  • 6
  • 34
  • 41
  • 1
    possible duplicate of [nodejs connect cannot find static](http://stackoverflow.com/questions/24346161/nodejs-connect-cannot-find-static) – Steve U Apr 14 '15 at 00:43
  • See my added comments above. – ChuckO Apr 14 '15 at 01:02
  • Are you able to request content from `http://localhost:5000/` after starting the script? The console will remain busy while the script is running and listening for requests. It may only appear to halt since no output is being logged to it. You can include [`morgan`](https://www.npmjs.com/package/morgan) to log server activity. – Jonathan Lonowski Apr 14 '15 at 01:13

0 Answers0