dialogflow-javascript-client
dialogflow-javascript-client copied to clipboard
Typescript compilation error
After installing api-ai-javascript beta 21 i get the following errors when attempting ng serve or ng build:
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"
]
}
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)
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"
]
}
Got it! It's working and now it's fine. Thank you!
Thanks for the help. That worked!
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
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
Facing same error with Angular CLI 6. "ERROR in No NgModule metadata found for 'AppModule'."
The same issue here, when added the "includes" I face the "ERROR in No NgModule metadata found for 'AppModule'." :'(
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).
@abhishekpoonia31 and @Juli15Boy did you find any fix for your issue? I am having the same problem
@jeroenouw great! is working for my!
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.
@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"
@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"
]
}
Thanks for the reply @dave-ramirez , i did the exact same. but still i'm getting the same error
@hemantkumar450 could you show me the file mentioned tsconfig.app.json
@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": [] } }
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 should i add include array in ts.config.json also?
actually i tried in both cases. i got the same error
@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" ] } }
@dave-ramirez
@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 can you post you AppModule file
@hemantkumar450 try using the --aot while building the app. It worked for me with the changes in place
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
}
}
}
For temporary solution to this, I have added the following check in your tsconfig.json file
"compilerOptions": {
"skipLibCheck": true
}
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
@comicflix-tech I have the same issue, did you find any solutions?