ionic-team / ionic-cli

The Ionic command-line interface
MIT License
2k stars 656 forks source link

TypeError: tsDiagnostic.file.getText is not a function #2889

Closed staskuban closed 6 years ago

staskuban commented 7 years ago

Hi there, im updatet my ionic env and now having theese errors when trying build ios --prod

TypeError: tsDiagnostic.file.getText is not a function
    at loadDiagnostic (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:32:44)
    at /Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:13:16
    at Array.map (<anonymous>)
    at Object.runTypeScriptDiagnostics (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:12:26)
    at /Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:231:59
    at step (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
    at Object.next (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
    at fulfilled (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
    at <anonymous>

ionic info

cli packages: (/Users/user/WebstormProjects/MDMProfileMobile/node_modules)

@ionic/cli-utils  : 1.18.0
ionic (Ionic CLI) : 3.18.0

global packages:

cordova (Cordova CLI) : 7.0.1 

local packages:

@ionic/app-scripts : 3.1.2
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.0.2
ios-deploy        : 1.9.2 
Node              : v8.9.1
npm               : 5.5.1 
OS                : macOS Sierra
Xcode             : Xcode 9.1 Build version 9B55 

Environment Variables:

ANDROID_HOME : /Users/user/Library/Android/sdk

Misc:

backend : pro
imhoffd commented 7 years ago

@staskuban May we have the full output of ionic build --prod? It's nice to know at which step these errors occur, just for sanity.

staskuban commented 7 years ago

@dwieeb , sure

Mini-Polzovatel:MDMProfileMobile user$ ionic cordova build ios --prod
Running app-scripts build: --prod --platform ios --target cordova
[09:25:54]  build prod started ... 
[09:25:54]  clean started ... 
[09:25:54]  clean finished in 4 ms 
[09:25:54]  copy started ... 
[09:25:56]  deeplinks started ... 
[09:25:58]  deeplinks finished in 2.00 s 
[09:25:58]  ngc started ... 
TypeError: tsDiagnostic.file.getText is not a function
    at loadDiagnostic (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:32:44)
    at /Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:13:16
    at Array.map (<anonymous>)
    at Object.runTypeScriptDiagnostics (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:12:26)
    at /Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:231:59
    at step (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
    at Object.next (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
    at fulfilled (/Users/user/WebstormProjects/MDMProfileMobile/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
    at <anonymous>
[09:26:23]  copy finished in 29.45 s 
staskuban commented 7 years ago

I reslove this issue. Problem with https://github.com/kadoshms/ionic2-autocomplete which crashes while compile with no errors. I updated check in logger-typescript fo if (tsDiagnostic.file && tsDiagnostic.file.getText) ...

soniyj commented 6 years ago

Hi @staskuban can you tell me how to apply the change on an existing project? Because I didn't find that file into node_modules/@ionic. Thanks

RanmalN commented 6 years ago

This fix should be merged

soniyj commented 6 years ago

@RanmalN i am still getting the error and not sure that has been merged in the latest ionic cli i am using 3.19.x.

lzkill commented 6 years ago

I've been compiling with --prod with no issues for several weeks. Now it produces this error out of nothing! Why is the PR closed?

5HARK commented 6 years ago

@soniyj in node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:29 change if (tsDiagnostic.file) { to if (tsDiagnostic.file && tsDiagnostic.file.getText) {

soniyj commented 6 years ago

hi @5HARK cool thank you I will try 👍

hervedevos commented 6 years ago

Same issue here, why is the PR closed ?

Run into this issue with ionic-cli 3.19.1 and ionic 4.5.2 packages

ionic info

cli packages: (/usr/lib/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

package.json

"dependencies": {
  "@angular/common": "5.2.0",
  "@angular/compiler": "5.2.0",
  "@angular/compiler-cli": "5.2.0",
  "@angular/core": "5.2.0",
  "@angular/forms": "5.2.0",
  "@angular/http": "5.2.0",
  "@angular/platform-browser": "5.2.0",
  "@angular/platform-browser-dynamic": "5.2.0",
  "@ionic-native/core": "4.5.2",
  "@ionic-native/splash-screen": "4.5.2",
  "@ionic-native/status-bar": "4.5.2",
  ...
},
"devDependencies": {
  @ionic/app-scripts: "3.1.8"
  ..
}
andremorata commented 6 years ago

Same problem here...

cli packages: (C:\Users\andre\AppData\Roaming\npm\node_modules) 

    @ionic/cli-utils  : 1.19.1                                  
    ionic (Ionic CLI) : 3.19.1                                  

local packages:                                                 

    @ionic/app-scripts : 3.1.8                                  
    Ionic Framework    : ionic-angular 3.9.2                    

System:                                                         

    Node : v7.10.1                                              
    npm  : 4.2.0                                                
    OS   : Windows 10                                           

package.json

    "@angular/common": "5.2.2",
    "@angular/compiler": "5.2.2",
    "@angular/compiler-cli": "5.2.2",
    "@angular/core": "5.2.2",
    "@angular/forms": "5.2.2",
    "@angular/http": "5.2.2",
    "@angular/platform-browser": "5.2.2",
    "@angular/platform-browser-dynamic": "5.2.2",
    "@ionic-native/core": "4.4.0",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/storage": "2.1.3",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18",
    "angular2-signaturepad": "^2.6.1",
    "animate.css": "^3.5.2",
    "font-awesome": "^4.7.0",
    "localforage": "^1.5.5",
    "moment": "^2.20.1",
    "ng2-ckeditor": "^1.1.9",
    "ngx-zxing": "^0.3.4",
    "text-encoding": "^0.6.4",
    "text-mask": "0.0.2",
    "text-mask-addons": "^3.7.1"
  },
  "devDependencies": {
    "@angular/cli": "1.6.6",
    "@ionic/app-scripts": "3.1.8",
    "typescript": "2.6.2"
  }
carys-cc commented 6 years ago

Hi, also got this problem. Compiling without --prod works, with --prod get the following:

$ ionic cordova build ios --prod Running app-scripts build: --prod --platform ios --target cordova [15:56:01] build prod started ... [15:56:01] clean started ... [15:56:01] clean finished in 1 ms [15:56:01] copy started ... [15:56:01] ngc started ... TypeError: this.compiler.compileAll is not a function at CodeGenerator.codegen (/Users/patrickchoi/Dropbox/Ionic/carys_dev/node_modules/@angular/compiler-cli/src/codegen.js:30:14) at Function.NgTools_InternalApi_NG_2.codeGen (/Users/patrickchoi/Dropbox/Ionic/carys_dev/node_modules/@angular/compiler-cli/src/ngtools_api.js:61:30) at Object.doCodegen (/Users/patrickchoi/Dropbox/Ionic/carys_dev/node_modules/@ionic/app-scripts/dist/aot/codegen.js:6:51) at /Users/patrickchoi/Dropbox/Ionic/carys_dev/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:42:30 at

soniyj commented 6 years ago

I got this problem long time ago and didn't find any solution about it

gmarab commented 6 years ago

@staskuban can you please reopen this PR? Maybe so someone will take a look. For my experience the problem occurs when you compile with --aot (therefore also with --prod) a project managed in lazy loading. I made today a project in lazy loading and the problem, which until this morning was not there, suddenly appeared.

huan commented 6 years ago

So do I. +1

For my experience the problem occurs when you compile with --aot (therefore also with --prod) a project managed in lazy loading. I made today a project in lazy loading and the problem, which until this morning was not there, suddenly appeared.

romain10009 commented 6 years ago

+1 I have this error on a lazy loaded project!

tolgaek commented 6 years ago

@zixia @romain10009 This turned out to be a mistake I made in an html file where I did *ngIf="phones & phones.length" (I forgot to put &&)

I'm not sure how this causes the issue but to debug your own issue, you can go to the node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js And add this following if condition and change the other if condition just above line 29

  if (tsDiagnostic && tsDiagnostic.file && !tsDiagnostic.file.getText) {
    console.log(tsDiagnostic.file.fileName);
  }

and change the if condition on line 29 to include the getText check

if (tsDiagnostic.file && tsDiagnostic.file.getText) {

Then run the build, and see which file has the typescript error

imhoffd commented 6 years ago

See this PR: https://github.com/ionic-team/ionic-app-scripts/pull/1365

This will be fixed in app-scripts 3.1.9

coolara commented 6 years ago

if found which cause the error tsDiagnostic.file.getText is not a function i create a custom component in my project in my component html when i use ngIf or ngFor like this example.html

<div *ngIf="text">
  {{text}}
</div>

it works ok like this

<div>
  {{text}}
</div>

why

coolara commented 6 years ago

烦躁,没人关注这个问题啊,难道我还得把angular的版本降到4.1.3 ionic 版本降到2.1.4才能解决问题吗

imhoffd commented 6 years ago

@ionic/app-scripts 3.1.9 is out with this a fix for this! Sorry for the delay!

coolara commented 6 years ago

u can run ./node_modules/.bin/ngc check what cause the error