0

i have installed node.js and i have my directory named nodeapps in c:/nodeapps. i am trying to create a static page server but when i call the file in command prompt it shows an error ! i am new to node.js so i copy this for creating the page from a book that is may not for the latest version that i am using.i am using windows 7 .if thats not the code then what is the function ? can anyone help me !

      Microsoft Windows [Version 6.1.7601]
     Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

     C:\Users\HP>cd c:/

     c:\>cd nodeapps

     c:\nodeapps>node server.js
     c:\nodeapps\server.js:4
     connect.static(__dirname)
          ^

    TypeError: connect.static is not a function
   at Object.<anonymous> (c:\nodeapps\server.js:4:15)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:141:18)
at node.js:933:3

     c:\nodeapps>

and this the code in the server.js

       var connect = require('connect');
      var port = 3000;
      connect.createServer(
      connect.static(__dirname)
      ).listen(port);
   console.log('connected via port '+port);
R.alim
  • 25
  • 1
  • 8
  • 1
    Please include the content of `C:/nodeapps/server.js` in your post. Without it, we can just speculate, since we don't see the actual code that's being executed. – phihag Mar 10 '16 at 22:44
  • Could you show your server.js ? – TMG Mar 10 '16 at 22:45
  • first i removed node_modules folder that comes by installing connect then i just installed "npm install serve-static" and then installed connect again and its works fine now ! thanks to all ! – R.alim Mar 10 '16 at 23:10

0 Answers0