I have a server, the code of the file index.js is shown below. I want to post it on https://dashboard.heroku.com/. But it does not start the command node inde.js
.
import http from 'http'
import express from 'express'
import bodyParser from 'body-parser';
const port = process.env.PORT || 8081;
const app = express();
const server = http.createServer(app);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));
app.get('/', (req, res) => res.status(200).send({
message: 'Welcome',
}));
server.listen(port, () => {
console.log(`Server running at ${port}`);
});
How to run it using the ES6 standard, command node inde.js
? I have installed babel7
node inde.js
. Gives an error messageimport http from 'http' ^^^^ SyntaxError: Unexpected identifier
. How to run my code with the commandnode inde.js
? – MegaRoks