I have been searching the whole day the reason of that problem so i've decided to post it:
I can't run my server using PORT=80 npm start
I get the following message :
Port 80 requires elevated privileges
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2018-03-26T19_52_49_813Z-debug.log
ubuntu@ip-172-31-32-30:~/mean/server$
Here is my code : Package.json
{
"name": "server",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"prod": "PORT=80 node ./bin/www"
},
"dependencies": {
"body-parser": "~1.18.2",
"cookie-parser": "~1.4.3",
"debug": "~3.1.0",
"express": "~4.16.2",
"jade": "~1.11.0",
"mongoose": "^5.0.1",
"morgan": "~1.9.0",
"serve-favicon": "~2.4.5"
}
}
my app.js
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var logger = require('morgan');
const mongoose = require('mongoose');
var app = express();
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname,'../public')))
mongoose.connect('mongodb://XXXXX:XXXXXX@ds12XXXX.mlab.com:2XXXX/angularXXXX', {}, (err) => {
if (err) {
console.log(err);
} else {
console.log('db connection ok!');
}
});
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, '../public/index.html'))
})
module.exports = app;
I'm using : NPM : 5.6.0 NODE : 8.10.0
Already tried : uninstall modules and npm install again, restart AWS instance, checked if port 80 is already used
Thank you for your help