0
votes

I have updated my project to angular 9, ng serve works fine and I have no error. Nativescript builds successfully but while installing on emulator fails with following stack error. I have tried pollyfills fixes and everything .Nothing fixed my problem.I have updated core-js to 3.6.5. Also imported 'import './pollyfills' on top of main.ts .That too didn't fix my problem.


package.json

"dependencies": {
    "@angular-devkit/build-angular": "~0.901.7",
    "@angular/animations": "~9.1.0",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "~9.1.0",
    "@angular/compiler": "~9.1.0",
    "@angular/compiler-cli": "^9.1.10",
    "@angular/core": "~9.1.0",
    "@angular/fire": "^5.2.1",
    "@angular/flex-layout": "^9.0.0-beta.31",
    "@angular/forms": "~9.1.0",
    "@angular/material": "^9.2.4",
    "@angular/platform-browser": "~9.1.0",
    "@angular/platform-browser-dynamic": "~9.1.0",
    "@angular/router": "~9.1.0",
    "@nativescript/angular": "^9.0.0",
    "@nativescript/core": "~6.5.0",
    "@nativescript/schematics": "^1.0.0",
    "@nativescript/theme": "~2.2.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@nstudio/nativescript-checkbox": "^1.0.0",
    "@stomp/ng2-stompjs": "^7.2.0",
    "@swimlane/ngx-charts": "^12.1.0",
    "@types/googlemaps": "^3.38.1",
    "acorn": "^6.1.1",
    "angular-gridster2": "^8.2.0",
    "angular2-uuid": "^1.1.1",
    "chart.js": "^2.9.3",
    "core-js": "^3.6.5",
    "fast-text-encoding": "^1.0.0",
    "firebase": "^7.0.0",
    "font-awesome": "^4.7.0",
    "i": "^0.3.6",
    "jwt-decode": "^2.2.0",
    "linkifyjs": "^2.1.8",
    "material-design-icons": "^3.0.1",
    "material-icons": "^0.3.1",
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.25",
    "nativescript-angular": "^8.21.0",
    "nativescript-couchbase-plugin": "^0.9.6",
    "nativescript-feedback": "^1.3.12",
    "nativescript-fontawesome": "^1.0.0",
    "nativescript-ng2-fonticon": "^1.3.4",
    "nativescript-ngx-fonticon": "^6.0.3",
    "nativescript-plugin-firebase": "^10.5.2",
    "nativescript-ui-listview": "^8.2.0",
    "nativescript-ui-sidedrawer": "^8.0.1",
    "ng-pick-datetime": "^7.0.0",
    "ng2-charts": "^2.3.0",
    "ng2-translate": "^5.0.0",
    "ngx-build-plus": "^8.0.3",
    "ngx-cookie-service": "^3.0.3",
    "ngx-logger": "^3.3.13",
    "ngx-mat-select-search": "^2.1.1",
    "ngx-select-ex": "^3.7.7",
    "ngx-tinymce": "^7.0.0",
    "npm": "^6.12.1",
    "p-try": "^2.2.0",
    "p3x-angular-compile": "^2020.4.192",
    "reflect-metadata": "~0.1.12",
    "rxjs": "~6.5.5",
    "rxjs-compat": "^6.5.5",
    "terser-webpack-plugin": "^1.3.0",
    "tinymce": "^5.0.8",
    "tns-core-modules": "^6.5.5",
    "tslib": "^1.10.0",
    "webpack": "^4.42.1",
    "xlsx": "^0.15.2",
    "zone.js": "^0.10.3"
  },
  "devDependencies": {
    "@angular/cli": "^9.1.7",
    "@angular/language-service": "^9.1.10",
    "@nativescript/schematics": "~1.0.0",
    "@nativescript/tslint-rules": "~0.0.5",
    "@ngtools/webpack": "~9.1.0",
    "@types/jasmine": "~3.3.13",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@types/webpack-env": "^1.13.9",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.5",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "nativescript-dev-webpack": "~1.5.0",
    "ng-mocks": "^9.0.0",
    "node-sass": "^4.12.0",
    "protractor": "~5.4.2",
    "tns-platform-declarations": "^6.5.1",
    "ts-node": "~8.2.0",
    "tslint": "~5.17.0",
    "typescript": "~3.8.3",
    "uglifyjs-webpack-plugin": "^2.1.3",
    "webpack-bundle-analyzer": "^3.3.2",
    "@angular/compiler-cli": "~9.1.0"
  },
  "nativescript": {
    "id": "com.sample.app",
    "tns-android": {
      "version": "6.5.1"
    },
    "tns-ios": {
      "version": "6.5.1"
    }
  }

tnsconfig.tns.ts

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "strict": false,
    "skipLibCheck": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom",
      "es6"
    ],
    "paths": {
      "core-js/es6/reflect": [
        "node_modules/core-js/proposals/reflect-metadata"
      ],
      "core-js/es6/*": [
        "node_modules/core-js/es"
      ],
      "core-js/es7/*": [
        "node_modules/core-js/es"
      ],
      "@src/*": [
        "src/*.android.ts",
        "src/*.ios.ts",
        "src/*.tns.ts",
        "src/*.web.ts",
        "src/*"
      ]
    }
  },
  "angularCompilerOptions": {
    "enableIvy": false
  }
}

ERROR:

Successfully transferred all files on device 49325649-F3BC-4A80-9109-BE05CB1C76BD.
Restarting application on device 49325649-F3BC-4A80-9109-BE05CB1C76BD...
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: Hot Module Replacement Enabled. Waiting for signal.
***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1   0x100e3d02e NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
2   0x100e7de18 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
3   0x1018795a2 ffi_closure_unix64_inner
4   0x101879fca ffi_closure_unix64
5   0x7fff23b9aa35 _CFXRegistrationPost1
6   0x7fff23b9a7a1 ___CFXNotificationPost_block_invoke
7   0x7fff23c988b3 -[_CFXNotificationRegistrar find:object:observer:enumerator:]
8   0x7fff23b9a0f6 _CFXNotificationPost
9   0x7fff2574bbf7 -[NSNotificationCenter postNotificationName:object:userInfo:]
10  0x7fff4808b5c2 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]
11  0x7fff48090f05 -[UIApplication _runWithMainScene:transitionContext:completion:]
12  0x7fff477c576d -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]
13  0x7fff47cb44c1 _UIScenePerformActionsWithLifecycleActionMask
14  0x7fff477c627f __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke
15  0x7fff477c5c8e -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
16  0x7fff477c60ac -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
17  0x7fff477c5941 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
18  0x7fff477c9f3f __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2
19  0x7fff47bd8c83 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:]
20  0x7fff47cd2dff _UISceneSettingsDiffActionPerformChangesWithTransitionContext
21  0x7fff477c9c5a __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
22  0x7fff47cd2d02 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext
23  0x7fff477c9ac8 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
24  0x7fff476206e7 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke
25  0x7fff4761f26c -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]
26  0x7fff47620411 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]
27  0x7fff4808f599 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:]
28  0x7fff47bfa7f5 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:]
29  0x7fff365d6165 -[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:]
30  0x7fff365fc4d8 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke.154
31  0x7fff365e0c45 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
JavaScript stack trace:
file: node_modules/@angular/compiler/fesm5/compiler.js:23397:0
at file: node_modules/@angular/compiler/fesm5/compiler.js:23202:0
at file: node_modules/@angular/compiler/fesm5/compiler.js:23094:0
at file: node_modules/@angular/compiler/fesm5/compiler.js:22962:0
at file: node_modules/@angular/compiler/fesm5/compiler.js:22769:0
at file: node_modules/@angular/compiler/fesm5/compiler.js:22856:0
at forEach([native code])
at file: node_modules/@angular/compiler/fesm5/compiler.js:22834:0
at file: node_modules/@angular/compiler/fesm5/compiler.js:22769:0
at file: node_modules/@angular/compiler/fesm5/compiler.js:22856:0
at forEach([native code])
at file: node_modules/@angular/compiler/fesm5/compiler.js:22834:0
at file: node_modules/@angular/compiler/fesm5/compiler.js:29076:0
at file: node_modules/@angular/compiler/fesm5/compiler.js:29057:0
at file: node_modules/@angular/compiler/fesm5/compiler.js:29015:0
at file: node_modules/@angular/core/fesm5/core.js:28712:0
at file: node_modules/@nativescript/angular/platform-common.js:90:0
at file: node_modules/@nativescript/angular/platform-common.js:157:0
at file: node_modules/@nativescript/core/data/observable/observable.js:124:0
at [native code]
at file: node_modules/@nativescript/core/application/application.ios.js:171:0
at file: node_modules/@nativescript/core/application/application.ios.js:163:0
at [native code]
at file: node_modules/@nativescript/core/application/application.ios.js:36:0
at UIApplicationMain([native code])
at run(file: node_modules/@nativescript/core/application/application.ios.js:312:0)
at file: node_modules/@nativescript/angular/platform-common.js:211:0
at file: node_modules/@nativescript/angular/platform-common.js:112:0
at file: node_modules/@nativescript/angular/platform-common.js:92:0
at file:///app/bundle.js:11202:144
at ./main.tns.ts<…>
JavaScript error:
file: node_modules/@angular/compiler/fesm5/compiler.js:23397:0: JS ERROR Error: Can't resolve all parameters for ApplicationModule: (?).
NativeScript caught signal 11.
Native Stack:
1   0x100e8dbe1 sig_handler(int)
2   0x7fff5245a5fd _sigtramp
3   0x100000006
4   0x7fff5248eb85 libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::step()
5   0x7fff52492e58 _Unwind_RaiseException
6   0x7fff502568bd __cxa_throw
7   0x7fff513fbc44 _objc_exception_destructor(void*)
8   0x100e3d56f NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool)
9   0x100e7de18 NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
10  0x1018795a2 ffi_closure_unix64_inner
11  0x101879fca ffi_closure_unix64
12  0x7fff23b9aa35 _CFXRegistrationPost1
13  0x7fff23b9a7a1 ___CFXNotificationPost_block_invoke
14  0x7fff23c988b3 -[_CFXNotificationRegistrar find:object:observer:enumerator:]
15  0x7fff23b9a0f6 _CFXNotificationPost
16  0x7fff2574bbf7 -[NSNotificationCenter postNotificationName:object:userInfo:]
17  0x7fff4808b5c2 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]
18  0x7fff48090f05 -[UIApplication _runWithMainScene:transitionContext:completion:]
19  0x7fff477c576d -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]
20  0x7fff47cb44c1 _UIScenePerformActionsWithLifecycleActionMask
21  0x7fff477c627f __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke
22  0x7fff477c5c8e -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
23  0x7fff477c60ac -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
24  0x7fff477c5941 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
25  0x7fff477c9f3f __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2
26  0x7fff47bd8c83 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:]
27  0x7fff47cd2dff _UISceneSettingsDiffActionPerformChangesWithTransitionContext
28  0x7fff477c9c5a __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
29  0x7fff47cd2d02 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext
30  0x7fff477c9ac8 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
31  0x7fff476206e7 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke
JS Stack:
UIApplicationMain([native code])
at run(file: node_modules/@nativescript/core/application/application.ios.js:312:0)
at file: node_modules/@nativescript/angular/platform-common.js:211:0
at file: node_modules/@nativescript/angular/platform-common.js:112:0
at file: node_modules/@nativescript/angular/platform-common.js:92:0
at file:///app/bundle.js:11202:144
at ./main.tns.ts(file:///app/bundle.js:11207:34)
at __webpack_require__(file: src/webpack/bootstrap:816:0)
at checkDeferredModules(file: src/webpack/bootstrap:43:0)
at webpackJsonpCallback(file: src/webpack/bootstrap:30:0)
at anonymous(file:///app/bundle.js:2:61)
at evaluate([native code])
at moduleEvaluation
at
at asyncFunctionResume
at
at promiseReactionJob
Successfully synced application com.ngdesk.ngdesk2 on device 49325649-F3BC-4A80-9109-BE05CB1C76BD.
1

1 Answers

0
votes

Please first of all try to upgrade your NativeScript Angular package from "nativescript-angular": "^8.21.0" to "nativescript-angular": "^9.0.0".

Then follow all the steps described here: Update guide Nativescript-Angular 9.

Besides if you have some more issues you can search through the NativeScript github issues to find many problems' solutions.

I managed to make it work with code sharing and Angular 9. It was not easy, at the beginning I got issues like you, even following the guide. What I can say is: follow the wiki/guide very closely (for example at one point I did an invisible mistake in the ngcc.config.js of a stupid curly brace), and double check every single file:

  1. the ngcc.config.js
  2. the tsconfig.json
  3. the tsconfig.tns.json
  4. check very carefully the package.json: you need to have exactly all the packages mentioned in the wiki, and with the same version numbers
  5. replace the imports to nativescript-angular with @nativescript/angular and tns-core-modules with @nativescript/core
  6. delete all the deep imports from @nativescript/angular and @nativescript/core within youe project (e.g.: import { somePackage } from '@nativescript/angular/deep/moreDeep' often can be now replaced with import { somePackage } from '@nativescript/angular')
  7. I got some issues with zone.js too, the app was starting with a fatal error related to zone; updating zone.js package to the very latest version solved everything
  8. when you are sure you have fixed all of the above points, make sure to clean everything and then rebuild:
    rm -rf node_modules/ platforms/ package-lock.json hooks yarn.lock
    tns platform remove android
    tns platform remove iOS
    tns platform add android
    tns platform add iOS

Hope this will help! For me at the end with all of this I have a working Angular 9+NativeScript+Ivy compiler enabled in code sharing.