I can't get Express working.now. I get the following error :
server.js
events.js:154
throw er; // Unhandled 'error' event
^
Error: listen EACCES 0.0.0.0:80
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at Server._listen2 (net.js:1214:19)
at listen (net.js:1263:10)
at Server.listen (net.js:1359:5)
at EventEmitter.listen (D:\Users\ME\Desktop\Utile\Web\_NodeJS\node_modules\express\lib\application.js:617:24)
at Object.<anonymous> (D:\Users\ME\Desktop\Utile\Web\_NodeJS\www.njstesting.herokuapp.com\server.js:20:5)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
I have the following structure :
-server.js
-public
--index.html
--css
---index_styles.css
With the following server.js code :
var express = require('express');
var path = require('path');
var app = express();
app.use(express.static(__dirname + '/public'));
app.use('/static', express.static(__dirname + '/public'));
app.get('/', function(request, response) {
res.sendFile('/index.html')
});
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
var port = process.env.PORT || 80;
app.listen(port, function() {
console.log("Node app is running at localhost:" + port);
});
Moreover, I have this index.html code that have already maked problems
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css\index_style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<style>
body {
background-color: #F5F5F5;
}
.father {
margin-left: 20px;
margin-right: 20px;
}
.sinput {
role: textbox;
border: 2px solid #444;
padding: 5px 5px;
background-color: #FFFFFF;
}
</style>
</head>
So, I want to run the server and get if possible the html file (index for root http://domain.com) along with the css and javascripts files. It also should be compatible with Heroku PaaS.
Thank you !