I am getting a “Cannot GET” error when I run my node.js application.
Usually that means the resource cannot be found in my folder structure, but I cannot figure out what is wrong with my folder structure to cause this. Or maybe I am asking the wrong question.
Could anybody please point me in the right direction?
Failed to load resource: the server responded with a status of 404 (Not Found) /favicon.ico votingapp1-olddognewtrix123.c9users.io/ Failed to load resource: the server responded with a status of 404 (Not Found)
Error: listen EADDRINUSE :::8080
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at Server._listen2 (net.js:1258:14)
at listen (net.js:1294:10)
at Server.listen (net.js:1390:5)
at Function.app.listen (/home/ubuntu/workspace/node_modules/express/lib/application.js:590:24)
at Object. (/home/ubuntu/workspace/server.js:29:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
I run the kill -9 commnd, then reran the application. I am still getting the Error: listen EADDRINUSE :::8080, meaning that port is in use. I have killed all processes, and am still getting this error.
@olddognewtrix123 try this solution in c9 app running issue. and re-start server again I think this might help to solve your problem.
I had the same issue yesterday but that was rails server solved with this tuts.
So, You mean your server is running but the server routes cannot get into the browser, right? If so your I believe that your routes setting not correct re-watch tuts or re-setup your proper server routes. if you got the message like
Cannot GET /
That means the server could not found your routes. What I know. I’m not NodeJS Expert but I also learning…
I was getting the Error: listen EADDRINUSE :::8080 originally because because I had repeated the app.get function in server.js
Once I corrected things so that the app.get function only shows up in routes/index.js like it is supposed to, I am no longer getting the EADDRINUSE :::8080 message BUT I AM STILL GETTING THE ‘Cannot GET’ message.
So I think it was what I originally expected - the server cannot find the app/routes folder for some reason I have yet to figure out.
'use strict';
var path = process.cwd();
module.exports = function (app){
// var express = require('express');
//var app = express();
app.get('/',function (req, res) {
res.sendFile(path + '/public/index.html');
});
};
and now it seems to be finding my routes folder.
But now there is a NEW error:
TypeError: res.sendFile is not a function
at /home/ubuntu/workspace/app/routes/index.js:31:17
at callbacks (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:164:37)
at param (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:138:11)
at pass (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:173:5)
at Object.router (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:33:10)
at next (/home/ubuntu/workspace/node_modules/connect/lib/proto.js:174:15)
at next (/home/ubuntu/workspace/node_modules/connect/lib/proto.js:149:78)
at next (/home/ubuntu/workspace/node_modules/connect/lib/proto.js:149:78)
at Object.expressInit [as handle] (/home/ubuntu/workspace/node_modules/express/lib/middleware.js:30:5)
This is maddening.
I am beginning to think that despite all the work I have already done (I have built all the microservices required by FCC so far) I really don’t understand some basic node.js functionality.
Is there a tutorial someone can suggest that will really help me figure out what the heck is going on here, specifically with these types of problems? I would be happy to take my time with another good tutorial that explains exactly how to get a complex node.js app to work, if it would help me understand why I am running into all these idiosyncrasies that none of the introductory tutorials seem to cover!.
@olddognewtrix123 I have not used yet res.sendFile but you can use .ejs plugin instead of .html and set that as a view engine gives the HTML output into browser/client-side.
Do you have any Premium video tuts?
If you want to go through here is a link below 12$ to purchase
FREE links are might already know
Traverse Media youtube channel you can choose a NodeJs videos