Pentium10 Pentium10 - 1 year ago 305
TypeScript Question

app.component.ts is not in project defined by tsconfig.json

So I get this error:

File C:/wamp/www/angular2_demo/GiphySearch/src/app/app.component.ts is
not in project defined by


my folder structure is


tsconfig.js has this content

"compileOnSave": false,
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"mapRoot": "",
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": false,
"rootDir": ".",
"sourceMap": true,
"sourceRoot": "/",
"target": "es5"

I tried changing
to be defines either as
but nothing worked. How should be properly configured?

Answer Source

As defined on tsconfig.json documentation:

The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project.

You have your tsconfig.json in your e2e directory, not in the src directory, where it should be according to the above link.

I also noticed that you have "sourceRoot": "/", would changing it to ./ help?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download