[英]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 文件C: /wamp/www/angular2_demo/GiphySearch/src/app/app.component.ts 不在 C:/ wamp / www / angular2_demo / GiphySearch / e2e / tsconfig.json定义的项目中
my folder structure is 我的文件夹结构是
/
/e2e/tsconfig.json
/src
(others)
tsconfig.js has this content tsconfig.js拥有此内容
{
"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. 我尝试将rootDir
或sourceRoot
更改为../
或../src
或/src
但没有任何效果。 How should be properly configured? 应该如何正确配置?
The NetBeans project is probably set up to index the whole ng2-cli directory as a single source root, which breaks this Plug-in because there are multiple tsconfig.json files under it (one in src/ and one in e2e/). NetBeans项目可能已设置为将整个ng2-cli目录索引为一个源根,这破坏了此插件,因为其下有多个tsconfig.json文件(一个在src /中,一个在e2e /中)。
In the project properties, under the "Sources" category, set the "Site Root Folder" and "Source Folder" to src. 在项目属性的“源”类别下,将“站点根文件夹”和“源文件夹”设置为src。 (You can also set "Selenium Tests Folder" to e2e if you want to edit that too). (如果您也想对其进行编辑,也可以将“ Selenium Tests Folder”设置为e2e)。
As defined on tsconfig.json documentation : 如tsconfig.json 文档中所定义:
The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. 目录中存在tsconfig.json文件,表明该目录是TypeScript项目的根目录。
You have your tsconfig.json
in your e2e directory, not in the src directory, where it should be according to the above link. 您的tsconfig.json
在您的e2e目录中,而不是在src目录中,根据上面的链接应位于该目录中。
I also noticed that you have "sourceRoot": "/",
would changing it to ./
help? 我还注意到您有"sourceRoot": "/",
将其更改为./
help吗?
I had the same problem, I replace the "outDir": "."
我遇到了同样的问题,我替换了"outDir": "."
for "outDir": ""
. 对于"outDir": ""
。
This is my current tsconfig.json
: 这是我当前的tsconfig.json
:
{
"compileOnSave": true,
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "",
"rootDir": "./_src/",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"moduleResolution": "node",
"noImplicitAny": false
},
"include" : [
"_src/**/*"
],
"exclude": [
"node_modules"
]
}
Check this out! 看一下这个! This works for me. 这对我有用。
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"files": [
"../src/app/app.component.ts",
"../src/app/app.component.spec.ts",
"../src/app/app.module.ts"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.