Closed mburger81 closed 7 years ago
FYI: there are other to open issues on ionic-angular and angular https://github.com/angular/angular/issues/20292 https://github.com/ionic-team/ionic/issues/13356
Have the same issue, ngc is not generating the ngfactory.js files.
I spent entire hours to understand the issue !! The error is not really understandable. However nothing related to app script. But to my/your code. Ensure that pathes to files are correct (case sensitive) If you are using lazyloading ensure that you followed the procedure carrefully (we say "à la lettre" in french) Ensure that all conponents/pages/pipes you are using are declared in either your custom module or app.module
Same here!! After upgrading to ng5 and re-installing all node modules, I am getting this err.
I think I got it, the problem is there are several errors, with always the same error message and ionic serve does work always correct which is the BIG problem
if you have a look on this a) don't have components, providers or directives in project which are not included in a module b) don't use *directives which are not imported in module, there is no error message for that c) don't import Modules in project which are not available, no error message d) refetor your rxjs to 5.5 e) check you lib if they are incompatible with ng5 most of the incompatibility is RxJS in ng5
Probably you think, all this point are for sure. But the big problem is most of the cases ionic serve run without error and in ionic build you have always the same error, so it is nearly impossible to find the errors, we take 2 days to discover all this errors.
All this errors can and can not be discovered by ionic serve, it depends on the combination of the errors. For example if there problems with directives the rxjs problems are not discovered.
I think I can reproduce this behavior also on an empty stupid new project
@mburger81 - @danbucholtz is currently working on this issue using the repo of a fellow Ionic employee that has the same issues. However, if you do duplicate this with a minimal project please post a link here. That may turn out to be very helpful.
All,
I am working with the angular team on resolving this issue. The ng cli
, which we largely use for AoT, is not reporting errors correctly. I will push them hard to add this sort of error tracking.
1. Component not assigned to ng module
a. NG - does not report an error
b. NGC CLI - "Error: Cannot determine the module for class DansComponent in /Users/dan/Desktop/appy/src/app/dan.component.ts! Add DansComponent to the NgModule to fix it."
2. Component assigned to multiple ng modules
a. NG - Does not report an error
b. NGC CLI - Error: Type DansComponent in /Users/dan/Desktop/appy/src/app/dan.component.ts is part of the declarations of 2 modules: AppModule in /Users/dan/Desktop/appy/src/app/app.module.ts and DanModule in /Users/dan/Desktop/appy/src/app/dan.module.ts! Please consider moving DansComponent in /Users/dan/Desktop/appy/src/app/dan.component.ts to a higher module that imports AppModule in /Users/dan/Desktop/appy/src/app/app.module.ts and DanModule in /Users/dan/Desktop/appy/src/app/dan.module.ts. You can also create a new NgModule that exports and includes DansComponent in /Users/dan/Desktop/appy/src/app/dan.component.ts then import that NgModule in AppModule in /Users/dan/Desktop/appy/src/app/app.module.ts and DanModule in /Users/dan/Desktop/appy/src/app/dan.module.ts.
3. Compile error in component
a. NG - ERROR in src/app/dan.component.ts(12,3): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
src/app/dan.component.ts(13,1): error TS1128: Declaration or statement expected.
b. Ionic -
c. NGC CLI - src/app/dan.component.ts(12,3): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
src/app/dan.component.ts(13,1): error TS1128: Declaration or statement expected.
In the meantime, to see the errors in your application and fix them, try running:
./node_modules/.bin/ngc
This should report any errors you have. If you don't have any errors and your application still doesn't work correctly, please let me know.
Thanks, Dan
@danbucholtz Great! As reported from some user, ionic2-auto-complete is one of the responsables, surely not the only one!
$ ./node_modules/.bin/ngc
Error at /home/bogomips/my_project/node_modules/ionic2-auto-complete/ionic2-auto-complete.d.ts.AutoCompleteComponent.html(42,23): ("mplate
[ngTemplateOutlet]="template || defaultTemplate"
[ERROR ->][ngOutletContext]="
{attrs:{ data: suggestion, keyword: keyword, labelAttribu")
Error at /home/bogomips/my_project/node_modules/ionic2-auto-complete/ionic2-auto-complete.d.ts.AutoCompleteComponent.html(40,15): ("gestion of suggestions" (tap)="select(suggestion);$event.srcEvent.stopPropagation()">
[ERROR ->]<ng-template
[ngTemplateOutlet]="template || defaultTemplate"
")
Thanks!
@bogomips so do you intend ionic components are ng5 incompotible?
This is fixed in 3.1.1
of @ionic/app-scripts
.
Thanks, Dan
Confirmed fixed. Thank you @danbucholtz
I can confirm I'm now seeing errors in .html files when running ./node_modules/.bin/ngc
.
@danbucholtz for me the error persists. @ionic/app-scripts@3.1.2 does not resolve the issue for me.
Different Error, still cryptic
$ rm -rf www/ node_modules/ && npm install && npm run ionic:build -- --prod
10:32:22] ionic-app-scripts 3.1.2
[10:32:22] build prod started ...
[10:32:22] clean started ...
[10:32:22] clean finished in less than 1 ms
[10:32:22] copy started ...
[10:32:23] deeplinks started ...
[10:32:23] deeplinks finished in 403 ms
[10:32:23] ngc started ...
[10:32:35] ionic-app-script task: "build"
[10:32:35] TypeError: tsDiagnostic.file.getText is not a function
TypeError: tsDiagnostic.file.getText is not a function
at loadDiagnostic (/home/bogomips/project/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:32:44)
at /home/bogomips/project/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:13:16
at Array.map (<anonymous>)
at Object.runTypeScriptDiagnostics (/home/bogomips/project/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:12:26)
at /home/bogomips/project/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:231:59
at step (/home/bogomips/project/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
at Object.next (/home/bogomips/project/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
at fulfilled (/home/bogomips/project/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
at <anonymous>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project@0.0.1 ionic:build: `ionic-app-scripts build "--prod"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@0.0.1 ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/bogomips/.npm/_logs/2017-11-14T09_32_35_161Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project@0.0.1 _prod: `npm run ionic:build -- --prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@0.0.1 _prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/bogomips/.npm/_logs/2017-11-14T09_32_35_184Z-debug.log
While ngc gives a human error:
$ ./node_modules/.bin/ngc
Error at /home/bogomips/project/node_modules/ionic2-auto-complete/ionic2-auto-complete.d.ts.AutoCompleteComponent.html(42,23): ("mplate
[ngTemplateOutlet]="template || defaultTemplate"
[ERROR ->][ngOutletContext]="
{attrs:{ data: suggestion, keyword: keyword, labelAttribu")
Error at /home/bogomips/project/node_modules/ionic2-auto-complete/ionic2-auto-complete.d.ts.AutoCompleteComponent.html(40,15): ("gestion of suggestions" (tap)="select(suggestion);$event.srcEvent.stopPropagation()">
[ERROR ->]<ng-template
[ngTemplateOutlet]="template || defaultTemplate"
")
For me version @3.1.2
resolve errors.
Thanks @danbucholtz I have been having these issues as well (when doing a --prod build) - upgrading to @3.1.2 got rid of the error I was getting and I also cleared the html errors I was seeing when I ran
./node_modules/.bin/ngc
However, when I do a --prod build now I get the following error:
[10:51:29] webpack started ...
<--- Last few GCs --->
173176 ms: Mark-sweep 1285.6 (1440.2) -> 1285.6 (1440.2) MB, 321.8 / 0.0 ms [allocation failure] [scavenge might not succeed].
173500 ms: Mark-sweep 1285.6 (1440.2) -> 1285.6 (1440.2) MB, 323.7 / 0.0 ms [allocation failure] [scavenge might not succeed].
173833 ms: Mark-sweep 1285.6 (1440.2) -> 1293.2 (1420.2) MB, 332.6 / 0.0 ms [last resort gc].
174170 ms: Mark-sweep 1293.2 (1420.2) -> 1303.4 (1420.2) MB, 337.3 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x3614a61cf781 <JS Object>
1: DoJoin(aka DoJoin) [native array.js:~129] [pc=0x9387a4aed19] (this=0x3614a6104381 <undefined>,w=0x35f42c259979 <JS Array[199]>,x=199,N=0x3614a61043c1 <true>,J=0x3614a61addd1 <String[1]: >,I=0x3614a61b7931 <JS Function ConvertToString (SharedFunctionInfo 0x3614a61526e1)>)
2: Join(aka Join) [native array.js:180] [pc=0x9387a3adf52] (this=0x3614a6104381 <undefined>,w=0x35f42c259979 <JS ...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
5: v8::internal::Runtime_StringBuilderJoin(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
6: 0x938767092a7
Ionic Info:
@ionic/cli-utils : 1.17.0
ionic (Ionic CLI) : 3.17.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.2
Cordova Platforms : android 6.2.3 ios 4.5.0
Ionic Framework : ionic-angular 3.9.2
System:
ios-deploy : 1.9.2
Node : v6.11.4
npm : 2.15.12
OS : macOS Sierra
Xcode : Xcode 9.1 Build version 9B55
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
Try to increase the memory fore node : https://github.com/driftyco/ionic-app-scripts/issues/779
Thanks for correcting the problem. It works for me ...
@danbucholtz and @kensodemann
On my linux machine It's really simple to simulate the bug which for me still persists.
I created an empty ionic project with ionic start
selecting the blank
starter template.
After that I remove the Home
component from app.module.ts
, this component is not loaded and the build script should give error
I created a repo to help you: https://github.com/mburger81/ionic-ng5-bug
On running./node_modules/.bin/ngc
I get this error
Error: Cannot determine the module for class HomePage in ~/ionic-ng5-bug/src/pages/home/home.ts! Add HomePage to the NgModule to fix it.
On running ionic cordova build android --prod --release
I get always the same error
Error: ./src/app/main.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in '~/ionic-ng5-bug/src/app'
resolve './app.module.ngfactory' in '~/ionic-ng5-bug/src/app'
using description file: ~/ionic-ng5-bug/package.json (relative path: ./src/app)
Field 'browser' doesn't contain a valid alias configuration
after using description file: ~/ionic-ng5-bug/package.json (relative path: ./src/app)
using description file: ~/ionic-ng5-bug/package.json (relative path: ./src/app/app.module.ngfactory)
no extension
Field 'browser' doesn't contain a valid alias configuration
~/ionic-ng5-bug/src/app/app.module.ngfactory doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
~/ionic-ng5-bug/src/app/app.module.ngfactory.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
~/ionic-ng5-bug/src/app/app.module.ngfactory.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
~/ionic-ng5-bug/src/app/app.module.ngfactory.json doesn't exist
as directory
~/ionic-ng5-bug/src/app/app.module.ngfactory doesn't exist
[~/ionic-ng5-bug/src/app/app.module.ngfactory]
[~/ionic-ng5-bug/src/app/app.module.ngfactory.ts]
[~/ionic-ng5-bug/src/app/app.module.ngfactory.js]
[~/ionic-ng5-bug/src/app/app.module.ngfactory.json]
[~/ionic-ng5-bug/src/app/app.module.ngfactory]
@ ./src/app/main.ts 2:0-60
at BuildError.Error (native)
at new BuildError (~/ionic-ng5-bug/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at callback (~/ionic-ng5-bug/node_modules/@ionic/app-scripts/dist/webpack.js:121:28)
at emitRecords.err (~/ionic-ng5-bug/node_modules/webpack/lib/Compiler.js:269:13)
at Compiler.emitRecords (~/ionic-ng5-bug/node_modules/webpack/lib/Compiler.js:375:38)
at emitAssets.err (~/ionic-ng5-bug/node_modules/webpack/lib/Compiler.js:262:10)
at applyPluginsAsyncSeries1.err (~/ionic-ng5-bug/node_modules/webpack/lib/Compiler.js:368:12)
at next (~/ionic-ng5-bug/node_modules/tapable/lib/Tapable.js:218:11)
at Compiler.compiler.plugin (~/ionic-ng5-bug/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at Compiler.applyPluginsAsyncSeries1 (~/ionic-ng5-bug/node_modules/tapable/lib/Tapable.js:222:13)
This is my environment:
cli packages: (/usr/lib/node_modules)
@ionic/cli-utils : 1.18.0
ionic (Ionic CLI) : 3.18.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.2
Cordova Platforms : android 6.3.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v6.11.5
npm : 5.5.1
OS : Linux 4.13
Environment Variables:
ANDROID_HOME : ~/android/sdk
Misc:
backend : legacy
Edit:
I updated also to latest Node LTS version 8.9.1
with the same result
The new ionic scripts now gives a better error description.
I've tracked the error to my declaration of a component in app.module.ts where I made a typo when importing like so:
import { StatusComponent } from '../components/status/status.component.ts'
where I added the .ts file extension to the end, and it lingered there for God knows when and didn't trow any compile errors. Removing the .ts extension fixed the problem.
In my case, I updated @ionic/app-scripts
to version 3.1.2 and works perfectly.
Now working for me too. Thanks.
I solved it with version 3.1.1
Hi,
I have installed @ionic/app-scripts on 3.1.2 and the error to be continued.
`cli packages: (C:\Users\Vinicius\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.18.0
ionic (Ionic CLI) : 3.18.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.2
Cordova Platforms : android 6.3.0
Ionic Framework : ionic-angular 3.9.2
System:
Node : v8.9.1
npm : 5.5.1
OS : Windows 8.1
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro`
###########################
I run npm install many times, but this error persists.
THE ERRO WHEN I RAN: ionic cordova build android --release --prod
C:\Program Files\nodejs8\PlusDeliveryV3\public_html>ionic cordova build android
--prod --release
Running app-scripts build: --prod --platform android --target cordova
[13:28:20] build prod started ...
[13:28:20] clean started ...
[13:28:20] clean finished in 3 ms
[13:28:20] copy started ...
[13:28:20] deeplinks started ...
[13:28:20] deeplinks finished in 358 ms
[13:28:20] ngc started ...
[13:28:31] ngc finished in 11.15 s
[13:28:31] preprocess started ...
[13:28:31] preprocess finished in 1 ms
[13:28:31] webpack started ...
[13:28:32] copy finished in 11.88 s
Error: ./src/app/main.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in 'C:\Program F
iles\nodejs8\PlusDeliveryV3\public_html\src\app'
resolve './app.module.ngfactory' in 'C:\Program Files\nodejs8\PlusDeliveryV3\pub
lic_html\src\app'
using description file: C:\Program Files\nodejs8\PlusDeliveryV3\public_html\pa
ckage.json (relative path: ./src/app)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\Program Files\nodejs8\PlusDeliveryV3\public_h
tml\package.json (relative path: ./src/app)
using description file: C:\Program Files\nodejs8\PlusDeliveryV3\public_html\
package.json (relative path: ./src/app/app.module.ngfactory)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Program Files\nodejs8\PlusDeliveryV3\public_html\src\app\app.module.n
gfactory doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\Program Files\nodejs8\PlusDeliveryV3\public_html\src\app\app.module.n
gfactory.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Program Files\nodejs8\PlusDeliveryV3\public_html\src\app\app.module.n
gfactory.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
C:\Program Files\nodejs8\PlusDeliveryV3\public_html\src\app\app.module.n
gfactory.json doesn't exist
as directory
C:\Program Files\nodejs8\PlusDeliveryV3\public_html\src\app\app.module.n
gfactory doesn't exist
[C:\Program Files\nodejs8\PlusDeliveryV3\public_html\src\app\app.module.ngfactor
y]
[C:\Program Files\nodejs8\PlusDeliveryV3\public_html\src\app\app.module.ngfactor
y.ts]
[C:\Program Files\nodejs8\PlusDeliveryV3\public_html\src\app\app.module.ngfactor
y.js]
[C:\Program Files\nodejs8\PlusDeliveryV3\public_html\src\app\app.module.ngfactor
y.json]
[C:\Program Files\nodejs8\PlusDeliveryV3\public_html\src\app\app.module.ngfactor
y]
@ ./src/app/main.ts 2:0-60
at new BuildError (C:\Program Files\nodejs8\PlusDeliveryV3\public_html\node_
modules\@ionic\app-scripts\dist\util\errors.js:16:28)
at callback (C:\Program Files\nodejs8\PlusDeliveryV3\public_html\node_module
s\@ionic\app-scripts\dist\webpack.js:121:28)
at emitRecords.err (C:\Program Files\nodejs8\PlusDeliveryV3\public_html\node
_modules\webpack\lib\Compiler.js:269:13)
at Compiler.emitRecords (C:\Program Files\nodejs8\PlusDeliveryV3\public_html
\node_modules\webpack\lib\Compiler.js:375:38)
at emitAssets.err (C:\Program Files\nodejs8\PlusDeliveryV3\public_html\node_
modules\webpack\lib\Compiler.js:262:10)
at applyPluginsAsyncSeries1.err (C:\Program Files\nodejs8\PlusDeliveryV3\pub
lic_html\node_modules\webpack\lib\Compiler.js:368:12)
at next (C:\Program Files\nodejs8\PlusDeliveryV3\public_html\node_modules\ta
pable\lib\Tapable.js:218:11)
at Compiler.compiler.plugin (C:\Program Files\nodejs8\PlusDeliveryV3\public_
html\node_modules\webpack\lib\performance\SizeLimitsPlugin.js:99:4)
at Compiler.applyPluginsAsyncSeries1 (C:\Program Files\nodejs8\PlusDeliveryV
3\public_html\node_modules\tapable\lib\Tapable.js:222:13)
at Compiler.afterEmit (C:\Program Files\nodejs8\PlusDeliveryV3\public_html\n
ode_modules\webpack\lib\Compiler.js:365:9)
C:\Program Files\nodejs8\PlusDeliveryV3\public_html>
Hi there! I had Updated in my package.json:
ionic/app-scripts: "3.1.2"
And it's working now. This is my configuration:
@ionic/cli-utils : 1.18.0 ionic (Ionic CLI) : 3.18.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.2
Cordova Platforms : android 6.3.0 ios 4.5.3
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 25.2.5
ios-deploy : 1.9.0
ios-sim : 5.0.12
Node : v6.11.0
npm : 5.5.1
OS : macOS Sierra
Xcode : Xcode 9.1 Build version 9B55
same as @viniciusrabbi . My config :
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.18.0
ionic (Ionic CLI) : 3.18.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.2
Cordova Platforms : android 6.3.0
Ionic Framework : ionic-angular 3.9.2
System:
Node : v9.0.0
npm : 5.5.1
OS : Linux 4.10
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
Did you remove the package-lock.json ? Becausr if you did not do it it reinstalled all the previous packages. To be sure : Delete package-lock.json Delete node_modules Run npm install
@speedfl My app is a fresh install from scratch, so I did not have to upgrade @ionic/app-scripts, it was in version 3.1.2 after fresh install from cli.
@speedfl I try your suggestion, but i don't have success :/
cli packages: (C:\Users\Vinicius\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.18.0 ionic (Ionic CLI) : 3.18.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.2 Cordova Platforms : android 6.3.0 Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 25.2.5 Node : v8.9.1 npm : 5.5.1 OS : Windows 8.1
Environment Variables:
ANDROID_HOME : C:\Users\Vinicius\AppData\Local\Android\android-sdk
Misc:
backend : pro
Did you run cmd
./node_modules/.bin/ngc
As suggested. It gives a better error description
Got this error when I followed a tutorial for Ionic.
cli packages: @ionic/cli-utils : 1.18.0 ionic (Ionic CLI) : 3.18.0 System: Node : v8.9.1 npm : 4.6.1 OS : Windows 10
Create a new project with super template and build for android with --prod
ionic start myNewSuperProject super cd myNewSuperProject ionic cordova build android --prod
Error: [09:49:36] webpack started ... [09:49:36] copy finished in 11.81 s [2K[GError: ./src/app/main.ts Module not found: Error: Can't resolve './app.module.ngfactory' in 'C:\SOURCE\Mobile\Ionic2 Test\myNewSuperProject\src\app' resolve './app.module.ngfactory' in 'C:\SOURCE\Mobile\Ionic2 Test\myNewSuperProject\src\app' using description file: C:\SOURCE\Mobile\Ionic2 Test\myNewSuperProject\package.json (relative path: ./src/app) Field 'browser' doesn't contain a valid alias configuration
Run:
./node_modules/.bin/ngc
Error:
error TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include'
paths were '["*/"]' and 'exclude' paths were '["node_modules","bower_components","jspm_packages"]'.
Hello to everyone. Here I found the hack to fix my Ionic configuration.
https://github.com/ionic-team/ionic/blob/master/CHANGELOG.md#390-2017-11-08
@radix21 And what is the hack in your opinion? I and probably also the other guys has followd the steps very well from the beginning, but without the hoped result. So perhaps I'm missing something on your post?
I opened a new bug for this #1315
@danbucholtz Hi, Dan, in your post above you said you are working with the angular team, and suggest running
./node_modules/.bin/ngc
to see what the errors are.
In my case, I'm starting with a fresh project based on AngularFire 5.3. I've followed their docs,
https://github.com/angular/angularfire2/blob/master/docs/ionic/v3.md
except I'm using lazy loading. So the "home" page is missing, and there's a login page instead. Also, I include ngx-charts. Here is my error:
Error: Unexpected value 'AngularFireAuthModule in /Users/glennlawyer/Projects/foobar/node_modules/angularfire2/auth/auth.module.d.ts'
imported by the module 'AppModule in
/Users/glennlawyer/Projects/foobar/src/app/app.module.ts'.
Please add a @NgModule annotation.
Is this an error in AngularFire?????
I've posted a git repo with my code:
https://github.com/glennlawyer/ionic-prod-flag-error
Project builds and runs fine without the --prod flag.
cli packages: (/Users/glennlawyer/Projects/foobar/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 browser 4.1.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.0.2
ios-sim : 5.0.8
Node : v8.4.0
npm : 5.3.0
OS : macOS Sierra
Xcode : Xcode 9.1 Build version 9B55
I SOLVED MY PROBLEM WITH NEXT STEPS
I have one App in IONIC 2, and I was update to Ionic 3. Because of this, i get the related erros above.
After testing many steps like without success (remove node_modules, remove package.json, run npm install), I get success with this:
Create a black app with Ionic 3 (e.g. ionic start myApp tabs)
Copy my Ionic 2 'pages' folder to new created project
Installing all plugins follow @latest after name of plugins e.g:
ionic cordova plugin add cordova-plugin-geolocation@lateste --variable GEOLOCATION_USAGE_DESCRIPTION="To locate you" npm install --save @ionic-native/geolocation
Replace all import { Observable } from 'rxjs/Rx'; to these two lines:
import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/catch';
run ionic cordova build android --prod --release
ionic/app-scripts: "3.1.2" the same error
Had same error. Ran ./node_modules/.bin/ngc
command and found out that there was a directive I had in my src
folder but never used it anywhere in my code, so it was not imported into app.module
.
After deleting that unused and unneeded directive, everything now build fine with ionic build --prod
If a directive, component, etc not being referenced anywhere in the code is going to cause aot errors, it would be nice if the tooling could run ngc for us in the background to give a helpful error. It would save hours of research in some cases.
They are already running ngc, have a look at log. But they don't show the right error (or somethingblike that) . Really don't know why they don't care anymore about it very.... But as you can see there are other opened bugs. I think you all should jump into it and don't go forward on post something here. I think they don't have a look on closed bugs.
Finally get rid of this error Thank to the answer of @rastographics
You will need to run ./node_modules/.bin/ngc
and following the instruction.
No need to downgrade hopefully.
In my case I just used some function in my component decorator. That is fully javascript-acceptable, but ngc dislike it
@Component({
selector:'my-comp',
animation:translationX('myTranslation')
})
translationX was a function for factoring some code, nothing wrong or important neither
Running:
ionic-app-scripts build --prod
Outputs:
Error: ./src/app/main.ts Module not found: Error: Can't resolve './app.module.ngfactory' in
'/..path../src/app' resolve './app.module.ngfactory' in
'/..path../src/app' using description file:
/..path../package.json (relative path: ./src/app) Field
'browser' doesn't contain a valid alias configuration after using description file:
/..path../package.json (relative path: ./src/app) using
description file: /..path../package.json (relative path:
./src/app/app.module.ngfactory) no extension Field 'browser' doesn't contain a valid alias configuration
/..path../src/app/app.module.ngfactory doesn't exist .ts Field
'browser' doesn't contain a valid alias configuration
/..path../src/app/app.module.ngfactory.ts doesn't exist .js
Field 'browser' doesn't contain a valid alias configuration
/..path../src/app/app.module.ngfactory.js doesn't exist .json
Field 'browser' doesn't contain a valid alias configuration
/..path../src/app/app.module.ngfactory.json doesn't exist as
directory /..path../src/app/app.module.ngfactory doesn't exist
[/..path../src/app/app.module.ngfactory]
[/..path../src/app/app.module.ngfactory.ts]
[/..path../src/app/app.module.ngfactory.js]
[/..path../src/app/app.module.ngfactory.json]
[/..path../src/app/app.module.ngfactory] @ ./src/app/main.ts
2:0-60
While running ./node_modules/.bin/ngc
gives me the correct error message:
Error: Error encountered resolving symbol values statically. Function calls are not supported.
Consider replacing the function or lambda with a reference to an exported function (position 18:31 in the original .ts file),
resolving symbol ɵ0 in /..path../src/app/app-routing.module.ts,
resolving symbol AppRoutingModule in /..path../src/app/app-routing.module.ts,
resolving symbol AppRoutingModule in /..path../src/app/app-routing.module.ts,
resolving symbol AppRoutingModule in /..path../src/app/app-routing.module.ts
And yes, this is the error in my case:
RouterModule.forRoot([
{
path: AppRoutingRouteNames.Dashboard,
loadChildren: () => DashboardModule
}
])
Which can be solved like this (btw):
export function myModuleEntryPoint() {
return MyModule;
}
RouterModule.forRoot([
{
path: AppRoutingRouteNames.Dashboard,
loadChildren: dashboardModuleEntryPoint
}
])
The default command does not lead me to the correct error.
This is resolved in 3.1.4
.
Thanks, Dan
@danbucholtz not resolved in my case, sorry, though the error still appears to be with AngularFireAuth
, not Ionic.
I'm working from this example:
https://github.com/glennlawyer/ionic-prod-flag-error.git
Cloned it into a fresh directory, then
npm install @ionic/app-scripts@latest --save
npm install
ionic cordova build android --prod --release
which gives the same error as before
ionic-prod-flag-error :)ionic cordova build android --prod --release
Running app-scripts build: --prod --platform android --target cordova
[09:56:38] build prod started ...
[09:56:38] clean started ...
[09:56:38] clean finished in 1 ms
[09:56:38] copy started ...
[09:56:38] deeplinks started ...
[09:56:38] deeplinks finished in 41 ms
[09:56:38] ngc started ...
[09:56:42] typescript error
Unexpected value 'AngularFireAuthModule in
/Users/glennlawyer/Projects/ionic-prod-flag-error/node_modules/angularfire2/auth/auth.module.d.ts' imported
by the module 'AppModule in /Users/glennlawyer/Projects/ionic-prod-flag-error/src/app/app.module.ts'. Please
add a @NgModule annotation.
Error: The Angular AoT build failed. See the issues above
at /Users/glennlawyer/Projects/ionic-prod-flag-error/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:237:55
at step (/Users/glennlawyer/Projects/ionic-prod-flag-error/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
at Object.next (/Users/glennlawyer/Projects/ionic-prod-flag-error/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
at fulfilled (/Users/glennlawyer/Projects/ionic-prod-flag-error/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
at <anonymous>
[09:56:42] copy finished in 3.68 s
As I mentioned in my earlier post, this might be an angularfire bug; however, you mentioned you interface with that team. The error from
./node_modules/.bin/ngc
is as before:
Error: Unexpected value 'AngularFireAuthModule in /Users/glennlawyer/Projects/ionic-prod-flag-error/node_modules/angularfire2/auth/auth.module.d.ts' imported by the module 'AppModule in /Users/glennlawyer/Projects/ionic-prod-flag-error/src/app/app.module.ts'. Please add a @NgModule annotation.
Would love whatever clues you might have on how to patch this!
ionic-prod-flag-error :)ionic info
cli packages: (/Users/glennlawyer/Projects/ionic-prod-flag-error/node_modules)
@ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 3.1.4
Cordova Platforms : android 6.4.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.0.2
ios-sim : 5.0.8
Node : v8.4.0
npm : 5.3.0
OS : macOS Sierra
Xcode : Xcode 9.1 Build version 9B55
Environment Variables:
ANDROID_HOME : /Users/glennlawyer/Library/Android/sdk
Misc:
backend : legacy
Hi there, I get this error while running command ionic cordova build android --prod
Any suggestions to solve this.
TypeError: tsDiagnostic.file.getText is not a function at loadDiagnostic (/var/www/bhagavadgita/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:32:44) at /var/www/bhagavadgita/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:13:16 at Array.map (<anonymous>) at Object.runTypeScriptDiagnostics (/var/www/bhagavadgita/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:12:26) at /var/www/bhagavadgita/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:235:59 at step (/var/www/bhagavadgita/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23) at Object.next (/var/www/bhagavadgita/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53) at fulfilled (/var/www/bhagavadgita/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58) at <anonymous>
Ionic info:
`cli packages: (/home/venkat/.nvm/versions/node/v8.7.0/lib/node_modules)
@ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.7
Cordova Platforms : android 6.3.0 browser 5.0.3
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v8.7.0
npm : 5.5.1
OS : Linux 3.13
Environment Variables:
ANDROID_HOME : /home/venkat/android-sdks
Misc:
backend : pro`
Hi @kotrakrishna I get the same
[11:44:08] ionic-app-script task: "build" [11:44:08] TypeError: tsDiagnostic.file.getText is not a function TypeError: tsDiagnostic.file.getText is not a function at loadDiagnostic (/Users/longphan/Projects/prudaily/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:32:65) at /Users/longphan/Projects/prudaily/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:13:16 at Array.map (
) at Object.runTypeScriptDiagnostics (/Users/longphan/Projects/prudaily/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:12:26) at /Users/longphan/Projects/prudaily/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:235:59 at step (/Users/longphan/Projects/prudaily/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23) at Object.next (/Users/longphan/Projects/prudaily/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53) at fulfilled (/Users/longphan/Projects/prudaily/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58) at
comand ./node_modules/.bin/ngc
error TS5052: Option 'emitDecoratorMetadata' cannot be specified without specifying option 'experimentalDecorators'.
anyone have solution, please help?
@drakgit How is your tsconfig.json looking?
The error says, the field experimentalDecorators is missing.
This is mine tsconfig.json:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"alwaysStrict": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"lib": [
"es2015",
"dom"
],
"typeRoots": [
"./node_modules/@types"
],
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
Hi StefanRein I try add "emitDecoratorMetadata": true,, but I still get same error my tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"noUnusedLocals": true,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "es2015",
"moduleResolution": "node",
"target": "es5",
"lib": [
"es2015",
"dom"
],
"paths": {
"@prudaily/core": ["../core/*"],
"@shared/*": ["./src/shared/*"]
},
"types": [
"@prudaily/ibm-mobilefirst",
"@prudaily/core/gtag",
"@prudaily/core/environments"
]
},
"include": [
"src/**/*.ts"
]
}
This is resolved for me in "ionic/app-scripts": "3.1.7"
Updating to latest ionic/app-scripts version gave a better error message.
npm install @ionic/app-scripts@latest --save-dev
It was a wrong path for styleUrls in a component to a non-existing file. Strangely it gave no error in development.
Hi guys In my case, I updated @ionic/app-scripts to version 3.1.2 and works perfectly.
Short description of the problem:
Updating to ionic3.9 and ng5 on doing a production build with
ionic cordova build android --prod --release
I get this errorWhat behavior are you expecting?
I was not able to check which could be the problem, I'm able to reproduce the error on a new build copying my production files. The problem is, sometime I can remove a file and the build works, sometimes it does also not work on removing the same file, in this case I have to remove an other random file to get it work again. So there is no logic on which file to remove to get it work again.
So at the end, I can not reproduce the error!
Which @ionic/app-scripts version are you using?