I was making my first typescript-node-express application.
To start with, I created my own tsconfig file which looks like
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"baseUrl": "./",
"outDir": "./build",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"importHelpers": true,
"types": [
"node"
],
"typeRoots": [
"node_modules/@types"
],
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modues"
]
}
}
And inside my src/app.ts I am initialising my express app
import * as express from "express";
class App {
constructor() {
this.app = express();
}
//TODO: What is public app: express.Application
public app: express.Application;
}
const app = new App().app;
const port = 4040;
app.listen(port, function() {
console.log('Express server listening on port ' + port);
});
Now, When I do ts-node ./src/app.ts I am getting the following error
error TS5023: unknown compiler option 'include'.
error TS5023: unknown compiler option 'exclude'.
at createTSError (/Users/an/.nvm/versions/node/v10.15.3/lib/node_modules/ts-node/src/index.ts:245:12) at reportTSError (/Users/an/.nvm/versions/node/v10.15.3/lib/node_modules/ts-node/src/index.ts:249:19) at Object.register (/Users/an/.nvm/versions/node/v10.15.3/lib/node_modules/ts-node/src/index.ts:260:36) at Object.<anonymous> (/Users/an/.nvm/versions/node/v10.15.3/lib/node_modules/ts-node/src/bin.ts:120:17) at Module._compile (internal/modules/cjs/loader.js:701:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3) at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)Unknown compiler
Can someone help me figure out why I am getting this error?
According to the handbook, include
and exclude
are supposed to be siblings of compilerOptions
, not children:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"baseUrl": "./",
"outDir": "./build",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"importHelpers": true,
"types": [
"node"
],
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modues"
]
}
The issue is because they do not belong in compiler options at all.
They should exist along-side compiler options like so:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"baseUrl": "./",
"outDir": "./build",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"importHelpers": true,
"types": [
"node"
],
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modues"
]
}
See the examples here: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#examples
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With