I am getting an exception
while importing module
Here is code
import * as express from 'express';
export class Server {
app: express.Application
constructor() {
const port = 3000 || process.env.PORT
this.app = express()
this.app.listen(port, () => {
console.log(`Listening on Port: ${port}`)
})
}
}
export default new Server()
Note:
I am creating API
with Angular 7
, both client & server apps have common node_modules
and other configuration files like package.json and angular.json
The same code, I am running with Angular 6
is working fine. Is there any configuration issue?
Update 1:
Old Angular 6
project, I created with Node v8.9.3
and new Angular 7
project with Node v10.14.2
and facing issue that server code is running with old project but giving stated error with new project.
Update 2:
When I changed it to
var express = require("express");
const app = express()
const port = 3001 || process.env.PORT
app.listen(port, () => {
console.log(`Listening on Port: ${port}`)
})
module.exports = app;
It worked fine... but I need to use ES6 syntax