TypeScript 编译中缺少 Angular5 :polyfills. ts &\main.ts

标签 angular typescript webpack angular-cli package.json

这是我的 Angular5 项目结构。

enter image description here

tsconfig.app.jsonpackage.json 都包含这个部分

 "include": [
      "/src/main.ts",
      "/src/polyfills.ts"
    ]

但是无论我怎么尝试,我仍然会得到这个错误:

    \polyfills.ts & \main.ts is missing from the TypeScript compilation. 
Please make sure it is in your tsconfig via the 'files' or 'include' property.

enter image description here 有人知道这里缺少什么吗?

  tsconfig.json
        {
          "compileOnSave": false,
          "compilerOptions": {
            "outDir": "./dist/out-tsc",
            "sourceMap": true,
            "declaration": false,
            "moduleResolution": "node",
            "emitDecoratorMetadata": true,
            "experimentalDecorators": true,
            "target": "es5",
            "typeRoots": [
              "node_modules/@types"
            ],
            "lib": [
              "es2017",
              "dom"
            ]
          }
        }
src/tsconfig.app.json
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": []
  },
  "include": [
    "main.ts",
    "polyfills.ts"
  ],
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

最佳答案

找到解决方案。问题是因为我在符号链接(symbolic link)目录中($HOME/dev -> d:\dev\) 移至原始目录 (d:\dev) 并运行您的命令,一切正常。

来源:https://github.com/angular/angular-cli/issues/9909

关于TypeScript 编译中缺少 Angular5 :polyfills. ts &\main.ts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49091956/

相关文章:

Angular 2 - 像#if 这样的预处理器指令

javascript - Node JS - 文件写入/Http 请求真正异步

css - Webpack 2 不会在 vue 文件中编译 css

css - 如何在 Aurelia 中包含额外的 CSS 文件?

javascript - 错误 :Cannot invoke an expression whose type lacks a call signature. 类型“没有兼容的 c ll 签名”

Angular AOT 编译器 - TypeError : this. compiler.analyzeModulesAsync 不是函数

javascript - 无法分配给对象 'property' 的只读属性 '#<Object>'

reactjs - 使用 'babel' 加载程序时,Node.js 的 Firebase 库会中断。具体是: "Uncaught TypeError: Cannot read property ' navigator' of undefined"

AngularFireList 不可分配给类型 'Observable<Response>

Angular - 缓存 http 响应的最佳方式