dialogflow-javascript-client icon indicating copy to clipboard operation
dialogflow-javascript-client copied to clipboard

Typescript compilation error

Open fickmj opened this issue 6 years ago • 44 comments

After installing api-ai-javascript beta 21 i get the following errors when attempting ng serve or ng build: screenshot_031418_114553_am

fickmj avatar Mar 14 '18 16:03 fickmj

Hi @fickmj

Make sure to add api-ai-javascript index.ts to your tsconfig files include (tsconfig.app.json and tsconfig.spec.json )

{
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts",
    "../node_modules/api-ai-javascript/index.ts",
    "./main.ts",
    "./polyfills.ts"
  ]
}

mboughaba avatar Mar 14 '18 18:03 mboughaba

Hi @mboughaba

I faced this error after your suggestion:

ERROR in ./src/main.ts Module build failed: Error: {PROJECT_PATH}/src/main.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. at AngularCompilerPlugin.getCompiledFile ({PROJECT_PATH}/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:674:23) at plugin.done.then ({PROJECT_PATH}/node_modules/@ngtools/webpack/src/loader.js:467:39) at process._tickCallback (internal/process/next_tick.js:109:7) ERROR in ./src/polyfills.ts Module build failed: Error: {PROJECT_PATH}/src/polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. at AngularCompilerPlugin.getCompiledFile (/{PROJECT_PATH}/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:674:23) at plugin.done.then ({PROJECT_PATH}/node_modules/@ngtools/webpack/src/loader.js:467:39)

joaovictortinoco avatar Mar 14 '18 19:03 joaovictortinoco

you need to add the missing files in your include.

The example I gave works with my setup 🤣 you need to adapt the relative paths in the include array

so I suggest that you change it to:

{
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts",
    "../node_modules/api-ai-javascript/index.ts",
    "./src/main.ts",
    "./src/polyfills.ts"
  ]
}

mboughaba avatar Mar 14 '18 19:03 mboughaba

Got it! It's working and now it's fine. Thank you!

joaovictortinoco avatar Mar 14 '18 19:03 joaovictortinoco

Thanks for the help. That worked!

fickmj avatar Mar 14 '18 20:03 fickmj

I have the same problem compiling with angular-cli. I added the file in the include array in tsconfig.spec.json and I get this error. I tries adding it under files and under include. Relative file path is correct.

/node_modules/api-ai-javascript/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 Format

TudorIoanMarin avatar Apr 14 '18 13:04 TudorIoanMarin

I did as suggested by @mboughaba, but I am now getting a new build error: ERROR in No NgModule metadata found for 'AppModule' It compiles fine without the 'api-ai-javascript' package and related code I am running Angular CLI 6.0.1. Please help

smanjesh avatar May 12 '18 17:05 smanjesh

Facing same error with Angular CLI 6. "ERROR in No NgModule metadata found for 'AppModule'."

abhishekpoonia31 avatar May 12 '18 19:05 abhishekpoonia31

The same issue here, when added the "includes" I face the "ERROR in No NgModule metadata found for 'AppModule'." :'(

globaljuli avatar May 17 '18 17:05 globaljuli

The fix from @mboughaba was not working for me. I was still gettings errors, so I changed some more in the src/tsconfig.app.json file (I'm using Angular 6), this was the old situation:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "types": [],
    "forceConsistentCasingInFileNames": false
  },
  "include": [
    "main.ts",
    "polyfills.ts"
  ],
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

New situation which fixed my errors:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "types": [],
    "forceConsistentCasingInFileNames": false
  },
  "include": [
    "../node_modules/api-ai-javascript/*.ts",
    "../node_modules/api-ai-javascript/**/*.ts",
    "main.ts",
    "polyfills.ts"
  ],
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts",
    "../node_modules/api-ai-javascript/ts/Request/TTSRequest.ts"
  ]
}

I have included all the typescript files and excluded the TTSRequest.ts file(this was not used in the library, commented out).

jeroenouw avatar May 19 '18 13:05 jeroenouw

@abhishekpoonia31 and @Juli15Boy did you find any fix for your issue? I am having the same problem

ghost avatar Jun 07 '18 12:06 ghost

@jeroenouw great! is working for my!

dave-ramirez avatar Jun 12 '18 00:06 dave-ramirez

Still not working for me :( I just getting ERROR in No NgModule metadata found for 'AppModule'. after adding "include" in tsconfig with angular 6. Ok looks like error is gone now. And i am just save app.module .. Don`t know why this drops error before.

Zefearr avatar Jun 29 '18 14:06 Zefearr

@jeroenouw , @mboughaba i'm still get the same issue with angular 6. Above solution didnt solve my issue

"ERROR in No NgModule metadata found for 'AppModule"

hemantkumar450 avatar Jul 12 '18 11:07 hemantkumar450

@Zefearr @hemantkumar450 This was the solution for me, they would have to modify the file tsconfig.app.json and you have to see something like that

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "types": []
  },
  "include": [
  "../node_modules/api-ai-javascript/*.ts",
  "../node_modules/api-ai-javascript/**/*.ts",
  "main.ts",
  "polyfills.ts"
  ],
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts",
    "../node_modules/api-ai-javascript/ts/Request/TTSRequest.ts"
  ]
}

dave-ramirez avatar Jul 12 '18 13:07 dave-ramirez

Thanks for the reply @dave-ramirez , i did the exact same. but still i'm getting the same error

hemantkumar450 avatar Jul 12 '18 13:07 hemantkumar450

@hemantkumar450 could you show me the file mentioned tsconfig.app.json

dave-ramirez avatar Jul 12 '18 13:07 dave-ramirez

@dave-ramirez my tsconfig.app.json code { "extends": "../tsconfig.json", "include": [ "../node_modules/api-ai-javascript/.ts", "../node_modules/api-ai-javascript/**/.ts", "main.ts", "polyfills.ts" ], "exclude": [ "src/test.ts", "**/*.spec.ts", "../node_modules/api-ai-javascript/ts/Request/TTSRequest.ts" ], "compilerOptions": { "outDir": "../out-tsc/app", "module": "es2015", "types": [] } }

hemantkumar450 avatar Jul 12 '18 13:07 hemantkumar450

The error that I see is that you are not calling the .ts files In the include section you have to call all the .ts using asterisk something like *.ts, You have your include section as follows:

"include": [
"../node_modules/api-ai-javascript/.ts",
"../node_modules/api-ai-javascript/**/.ts",
"main.ts",
"polyfills.ts"
]

And should correct the error add the asterisk before the .ts, something like:

  "include": [
  "../node_modules/api-ai-javascript/*.ts",
  "../node_modules/api-ai-javascript/**/*.ts",
  "main.ts",
  "polyfills.ts"
  ]

let me know if it works

dave-ramirez avatar Jul 12 '18 13:07 dave-ramirez

@dave-ramirez should i add include array in ts.config.json also?

actually i tried in both cases. i got the same error

hemantkumar450 avatar Jul 12 '18 13:07 hemantkumar450

@dave-ramirez ,As per your instruction i did the same. but no luck { "compileOnSave": false, "include": [ "node_modules/api-ai-javascript/*.ts", "node_modules/api-ai-javascript/**/*.ts" ], "compilerOptions": { "baseUrl": "./", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2017", "dom" ] } }

hemantkumar450 avatar Jul 12 '18 13:07 hemantkumar450

@dave-ramirez image

hemantkumar450 avatar Jul 12 '18 13:07 hemantkumar450

@dave-ramirez , @jeroenouw , @mboughaba here's my package.JSON

{ "name": "chatbot", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^6.0.0", "@angular/common": "^6.0.0", "@angular/compiler": "^6.0.0", "@angular/core": "^6.0.5", "@angular/forms": "^6.0.0", "@angular/http": "^6.0.0", "@angular/platform-browser": "^6.0.0", "@angular/platform-browser-dynamic": "^6.0.0", "@angular/router": "^6.0.0", "core-js": "^2.5.7", "rxjs": "^6.2.1", "rxjs-compat": "^6.2.1", "zone.js": "^0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "~0.6.8", "@angular/cli": "6.0.8", "@angular/compiler-cli": "^6.0.0", "@angular/language-service": "^6.0.0", "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "api-ai-javascript": "^2.0.0-beta.21", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~1.7.1", "karma-chrome-launcher": "~2.2.0", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "~1.4.2", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.3.0", "ts-node": "~5.0.1", "tslint": "~5.9.1", "typescript": "^2.7.2" } }`

tsconfig.app.json { "extends": "../tsconfig.json", "exclude": [ "test.ts", "**/*.spec.ts" ], "include": [ "../node_modules/api-ai-javascript/*.ts", "../node_modules/api-ai-javascript/**/*.ts", "main.ts", "polyfills.ts" ], "compilerOptions": { "outDir": "../out-tsc/app", "baseUrl": "./", "module": "es2015", "types": [] } }

but i got the same error ERROR in No NgModule metadata found for 'AppModule'.

please help me out. Thanks in advance.

hemantkumar450 avatar Jul 12 '18 15:07 hemantkumar450

@hemantkumar450 can you post you AppModule file

ravitejagunty avatar Aug 01 '18 20:08 ravitejagunty

@hemantkumar450 try using the --aot while building the app. It worked for me with the changes in place

manojjayaraman avatar Aug 08 '18 15:08 manojjayaraman

If you are using Angular 6. Step 1 : In the service file import ApiAiClient from api-ai-javascript/es6/ApiAiClient

import { ApiAiClient } from 'api-ai-javascript/es6/ApiAiClient';

Step 2: Then open tsconfig.json and bypass the index.ts file.

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ],
   "paths": {
      "api-ai-javascript/*": ["node_modules/api-ai-javascript/es6/ApiAiClient"] //bypass the index.ts
    }
  }
}

aravindvakil avatar Nov 02 '18 07:11 aravindvakil

For temporary solution to this, I have added the following check in your tsconfig.json file

  "compilerOptions": {
    "skipLibCheck": true
  }

vikram06 avatar Dec 10 '18 04:12 vikram06

ERROR in ./node_modules/angular4-carousel/index.ts Module build failed (from ./node_modules/@ngtools/webpack/src/index.js): Error: E:\Slider\single\node_modules\angular4-carousel\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 Format (https://goo.gl/jB3GVv). at AngularCompilerPlugin.getCompiledFile (E:\Slider\single\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:752:23) at plugin.done.then (E:\Slider\single\node_modules@ngtools\webpack\src\loader.js:41:31) at at process._tickCallback (internal/process/next_tick.js:188:7)

comicflix-tech avatar Jan 11 '19 08:01 comicflix-tech

image

comicflix-tech avatar Jan 11 '19 08:01 comicflix-tech

@comicflix-tech I have the same issue, did you find any solutions?

BassamHabash avatar Feb 03 '19 15:02 BassamHabash