简体   繁体   English

app.component.ts不在tsconfig.json定义的项目中

[英]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. 我尝试将rootDirsourceRoot更改为../../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.

相关问题 没有为项目或全局定义合适的部署服务器 - No suitable Deployment Server is defined for the project or globally Netbeans错误“属性目标未在组件outputStylesheet中定义” - Netbeans errors “The attribute target is not defined in the component outputStylesheet” Netbeans 11.2:没有为项目或全局定义合适的部署服务器 - Netbeans 11.2: No suitable Deployment Server is defined for the project or globally Java应用程序中具有分层特性的组件? - a component for having layered characteristic in java app? Androiod Cordova中的应用程序和项目名称 - App and Project Name in androiod cordova 在MHP项目(Netbeans)中导入JSON.simple - Importing JSON.simple in a MHP project (Netbeans) Netbeans Maven项目:JAVA_HOME未正确定义 - Netbeans Maven project: JAVA_HOME is not defined correctly NETBEANS 7.4:“未为名称定义任何标记:注册” +“未为命名空间http://java.sun.com/jsf/composite/my_composite_component找到库” - NETBEANS 7.4: “no tag was defined for name: register” + “No library found for namespace http://java.sun.com/jsf/composite/my_composite_component” Netbeans GUI将文本字段值传递给App中未在View中定义的操作 - Netbeans GUI passing textfield values to action defined in App not in View 将库添加到Netbeans中的Vaadin Web App项目 - Add library to Vaadin Web App project in Netbeans
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM