【问题标题】:Typescript error compiling Aurelia with Intellij Idea使用 Intellij Idea 编译 Aurelia 时出现打字稿错误
【发布时间】:2016-08-04 21:10:24
【问题描述】:

使用 IntelliJ Idea 2016.2 我在编译使用

生成的 aurelia 项目时遇到了这个错误
aurelia_project/generators/binding-behavior.ts(2,52): error TS2307: Cannot find module 'aurelia-cli'.

aurelia cli 显然在 node_modules 中用于本地和全局。给定该文件甚至应该编译的路径?也许应该忽略它?

如果我了解 tsconfig 和我的想法设置,甚至不应该构建这些

{
  "compileOnSave": false,
  "compilerOptions": {
    "sourceMap": true,
    "target": "es5",
    "module": "amd",
    "declaration": false,
    "noImplicitAny": false,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "lib": ["es2015", "dom"]
  },
  "exclude": [
    "node_modules"
  ],
  "filesGlob": [
    "./src/**/*.ts",
    "./test/**/*.ts",
    "./typings/index.d.ts",
    "./custom_typings/**/*.d.ts"
  ],
  "atom": {
    "rewriteTsconfig": false
  }
}

au run --watch 开始正常

如何解决此问题,以便 Idea 可以无错误地构建项目?

【问题讨论】:

    标签: intellij-idea typescript aurelia


    【解决方案1】:

    在终端中运行编译器时会遇到同样的问题 - Idea (https://youtrack.jetbrains.com/issue/WEB-17991) 和 tsc 本身都不支持 filesGlob,这是 atom-specific 选项。所以所有文件都被编译。而且,由于在项目中找不到 'aurelia-cli' 的 .d.ts,因此会报告编译器错误。

    要解决这个问题,您可以更改 tsconfig.json 以确保只编译需要的文件,或者禁用 TypeScript 编译器并使用 aurelia 来构建您的项目

    【讨论】:

      【解决方案2】:

      将生成器文件夹添加到排除列表 - 该文件夹由 Aurelia CLI 在内部使用(如果我没记错的话)。

      "exclude": [
        "node_modules",
        "aurelia_project"
      ],
      

      【讨论】:

      • 我可以查一下,但由于这是一个 SO 问题,而且我是 typescript 的新手,也许您可​​以提供所需的 json?
      • 更新了答案以包含相关的排除部分
      猜你喜欢
      • 1970-01-01
      • 2015-05-10
      • 2018-04-20
      • 2017-06-26
      • 1970-01-01
      • 2016-08-21
      • 2018-07-04
      • 2020-01-17
      • 2017-07-18
      相关资源
      最近更新 更多