Pentium10 Pentium10 - 1 month ago 35
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

C:/wamp/www/angular2_demo/GiphySearch/e2e/tsconfig.json


my folder structure is

/
/e2e/tsconfig.json
/src
(others)


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
rootDir
or
sourceRoot
to be defines either as
../
or
../src
or
/src
but nothing worked. How should be properly configured?

Answer

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?

Comments