Starting an Angular2 project and setting up the server with express and Angular CLI version 1.0.0-beta.25.5 has been challenging for me.
The file structure looks something like this:
project root
|-server
|-server.ts
|-src
|-app
When attempting to run nodemon server.ts
, I encounter an error message that is puzzling:
https://i.sstatic.net/NdfL4.png
Despite imports working in other parts of my application, the issue with this import statement remains unresolved. There are no indication of any incorrect imports in VS Code errors either. Both express
and body-parser
have been installed using npm install --save
, along with @types/express
(--save-dev
). What could be causing this import statement to not work, and how can it be fixed?
server.ts
import * as express from 'express';
import {Application} from 'express';
import {apiFoods} from './api/apiFoods';
const bodyParser = require('body-parser');
const app: Application = express();
app.use(bodyParser.json());
apiFoods(app);
app.listen(8090, () => {
console.log('Server is now running on port 8090 ...');
});