Cannot read property 'json' of undefined
at Object. (C:\web\learnTypescript\dist\index.js:7:40)
dist/index.js:7
app_1.default.use(body_parser_1.default.json());
I created a simple project to learn TypeScript. I have my dependencies and their @types counterparts installed but I continue to get the above error when I try to start node node dist/index.js.
tsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"module": "commonjs",
"target": "es6",
"outDir": "dist"
},
"include": [ "src/**/*" ],
"exclude": [ "node_modules" ]
}
src/index.ts
import app from './app'
import bodyParser from 'body-parser'
/* more imports */
app.use(bodyParser.json());
/* more code follows */
dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const app_1 = require("./app");
const body_parser_1 = require("body-parser");
/* more requires */
app_1.default.use(body_parser_1.default.json());
/* more code follows */
import * as bodyParser from 'body-parser';?