node.js - How to run project based on Nodejs, when getting message like Unresponsive script? -


when run nodejs project, message unresponsive script

i got 1 project on git-hub based on angularjs-rickshaw. based on nodejs, bower. project: ngyewch/angular-rickshaw
demo of above project: demo

i want run above project on local system. installed every thing (nodejs, npm, bower). when type http://localhost:3000/ nothing, new in nodejs, please me on this. correct url?

[neelabh@localhost angular-rickshaw]$ node server.js  connect.multipart() removed in connect 3.0 visit https://github.com/senchalabs/connect/wiki/connect-3.0 alternatives connect.limit() removed in connect 3.0 server running @ http://localhost:3000/ 

i getting following type of message if ran 1.http://localhost:3000/ or 2. http://localhost:3000/#/home enter image description here

server.js

'use strict';  var fs =require('fs');      //for image upload file handling  var express = require('express'); var app = express();  var port =3000; var host ='localhost'; var serverpath ='/'; var staticpath ='/';  //var staticfilepath = __dirname + serverpath;  var path = require('path');  var staticfilepath = path.join(__dirname, serverpath); // remove trailing slash if present if(staticfilepath.substr(-1) === '/'){     staticfilepath = staticfilepath.substr(0, staticfilepath.length - 1); }  app.configure(function(){     // compress static content     app.use(express.compress());     app.use(serverpath, express.static(staticfilepath));        //serve static files      app.use(express.bodyparser());      //for post content / files - not sure if necessary? });  //catch route serve index.html (main frontend app) app.get('*', function(req, res){     res.sendfile(staticfilepath + staticpath+ 'index.html'); });   app.listen(3000, function () {     console.log('server running @ http://' + host + ':' + port + '/');  }) //app.listen(port);  //console.log('server running @ http://'+host+':'+port.tostring()+'/'); 

looking @ https://github.com/ngyewch/angular-rickshaw/blob/gh-pages/server.js, console.log('server running @ http://'+host+':'+port.tostring()+'/') should callback listen call. otherwise console.log gets executed, if server doesn't start properly.

the correct way is:

 app.listen(3000, function () {     console.log('server running @ http://' + host + ':' + port + '/');  }); 

for staticfilepath , in other path-related parts should use path.join:

 var path = require('path');  var staticfilepath = path.join(__dirname, serverpath); 

ultimately it's best move static files public directory , serve express.static middleware:

'use strict';   var express = require('express');  var app = express();   var port = 3000;   app.use(express.static('public'));   app.listen(port, function () {    console.log('server running @ http://' + host + ':' + port + '/');  }); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -