Angular5 :polyfills.ts & \main.ts is missing from the TypeScript compilation

笑着哭i 提交于 2020-01-01 08:20:00

问题


This is my Angular5 project structure.

Both tsconfig.app.json and package.json contain this section

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

But no matter what I try I still get this error:

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

Anyone has idea what's missing 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"
  ]
}

回答1:


Found the solution. The problem is because I was in a symbolic link directory ($HOME/dev -> d:\dev\ ) Move to the original directory (d:\dev) and run your commands and it works.

Source: https://github.com/angular/angular-cli/issues/9909




回答2:


It's possibly because you're using an absolute path.

Try changing from:

"/src/main.ts",

to

"src/main.ts",

(Or possibly just "main.ts")




回答3:


I also experienced this problem for a while, and I solved it by just changing the location of my project. I put it in the disk other than that of the system (example: d :, e: ...)



来源:https://stackoverflow.com/questions/49091956/angular5-polyfills-ts-main-ts-is-missing-from-the-typescript-compilation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!