Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module build failed: Error: index.ts is missing from the TypeScript compilation

Tags:

angular5

Description of the project: My project is downloading to node_module via package.json

Package.json

....
   dependencies:{
       ....
       "@myllc/application-core": "git+ssh://[email protected]/myllc/application-core.git",
       "@myllc/application-shared":"git+ssh://[email protected]/myllc/application-shared.git",

   }
   ....

Gotting error when doing "npm build":

ERROR in ./node_modules/@myllc/application-core/index.ts Module build failed: Error: /var/www/frontend-skeleton/node_modules/@myllc/application-core/index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Form at (https:// goo.gl/jB3GVv).

This appear after upgrade from Angular4 to Angular5: Tsconfig:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "lib": [
      "es2016",
      "dom"
    ],
    "typeRoots": [
      "node_modules/@types"
    ]

  }

}

I tried to add

"include": [
    "./node_modules/@myllc/**/*"
  ]

but there appear same error at deeper folder .ts file. Also founding https://github.com/angular/angular-cli/issues/8284 but nothing solved this error.

What is the solution?

like image 653
user3054630 Avatar asked Feb 01 '18 11:02

user3054630


1 Answers

The solution is found in index.ts is not part of the compilation. #8284 by tapaz1 :

2 tsconfig.json files, one at the root of the app, and the other inside the src folder (one level down from the root) named tsconfig.app.json that extends the main tsconfig.json. I explicitly added the package that I needed that wasn't being transpiled by Typescript in the "include" array, and like a lot of people here I was getting the *.spec.ts files included despite having them in "exclude" option, so I removed it from the tsconfig.json. The fix was adding the "exclude" option to the second (extended) tsconfig.app.json file.

tsconfig.app.json:

{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../dist",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
"../node_modules/your_package/**/*.spec.ts"
]
}
like image 194
user7294900 Avatar answered Nov 17 '22 09:11

user7294900