nativescript-schematics: ns preview - PLAYGROUND RELATED ONLY - Type AppRoutingModule does not have 'ngModuleDef' property.

Environment Provide the content of the package.json file in the project:

{ “name”: “workspace2”, “nativescript”: { “id”: “org.nativescript.workspace2”, “tns-android”: { “version”: “6.5.3” } }, “version”: “0.0.0”, “scripts”: { “ng”: “ng”, “start”: “ng serve”, “build”: “ng build”, “test”: “ng test”, “lint”: “ng lint”, “e2e”: “ng e2e”, “android”: “tns run android --no-hmr”, “ios”: “tns run ios --no-hmr”, “mobile”: “tns run”, “preview”: “tns preview”, “ngcc”: “ngcc --properties es2015 module main --first-only”, “postinstall”: “npm run ngcc” }, “private”: true, “dependencies”: { “@angular/animations”: “~10.0.0”, “@angular/common”: “~10.0.0”, “@angular/compiler”: “~10.0.0”, “@angular/core”: “~10.0.0”, “@angular/forms”: “~10.0.0”, “@angular/platform-browser”: “~10.0.0”, “@angular/platform-browser-dynamic”: “~10.0.0”, “@angular/router”: “~10.0.0”, “core-js”: “^2.6.9”, “@nativescript/angular”: “~10.0.0”, “@nativescript/core”: “rc”, “@nativescript/theme”: “~2.2.1”, “reflect-metadata”: “~0.1.12”, “rxjs”: “~6.5.5”, “tslib”: “1.10.0”, “zone.js”: “~0.10.2” }, “devDependencies”: { “@angular/cli”: “~10.0.0”, “@angular/compiler-cli”: “~10.0.0”, “@angular-devkit/build-angular”: “~0.1000.2”, “@nativescript/tslint-rules”: “~0.0.5”, “@types/jasmine”: “~3.5.0”, “@types/jasminewd2”: “~2.0.3”, “@types/node”: “^12.11.1”, “codelyzer”: “^5.1.2”, “jasmine-core”: “~3.5.0”, “jasmine-spec-reporter”: “~4.2.1”, “karma”: “~4.4.1”, “karma-chrome-launcher”: “~3.1.0”, “karma-coverage-istanbul-reporter”: “~2.1.0”, “karma-jasmine”: “~3.0.1”, “karma-jasmine-html-reporter”: “^1.4.2”, “@nativescript/webpack”: “~2.0.0”, “protractor”: “~5.4.3”, “ts-node”: “~8.3.0”, “tslint”: “~6.1.0”, “typescript”: “~3.9.0”, “node-sass”: “^4.7.1” } }

Describe the bug The error occurs after I run tns preview (or npm run preview) and scan the QR CODE.

Bellow is the error log Copying template files… Platform android successfully added. v6.5.3 Preparing project… File change detected. Starting incremental webpack compilation…

webpack is watching the files…

Hash: b23597466ab3e940e588 Version: webpack 4.43.0 Time: 6268ms Built at: 08/01/2020 11:49:01 AM Asset Size Chunks Chunk Names bundle.js 26.5 KiB bundle [emitted] bundle package.json 112 bytes [emitted] runtime.js 77.1 KiB runtime [emitted] runtime tns-java-classes.js 0 bytes [emitted] vendor.js 345 KiB vendor [emitted] vendor Entrypoint bundle = runtime.js vendor.js bundle.js [./app.css] 1.02 KiB {bundle} [built] [./app/app-routing.module.tns.ts] 1.02 KiB {bundle} [built] [./app/app.component.ts] 905 bytes {bundle} [built] [./app/app.module.tns.ts] 1.56 KiB {bundle} [built] [./app/app.routes.ts] 245 bytes {bundle} [built] [./app/home/home.component.ts] 1.28 KiB {bundle} [built] [./main.tns.ts] 2.3 KiB {bundle} [built] [@angular/core] external “@angular/core” 42 bytes {bundle} [built] [@nativescript/angular] external “@nativescript/angular” 42 bytes {bundle} [built] [@nativescript/core] external “@nativescript/core” 42 bytes {bundle} [built] [@nativescript/core/bundle-entry-points] external “@nativescript/core/bundle-entry-points” 42 bytes {bundle} [built] [@nativescript/core/ui/frame] external “@nativescript/core/ui/frame” 42 bytes {bundle} [built] [@nativescript/core/ui/frame/activity] external “@nativescript/core/ui/frame/activity” 42 bytes {bundle} [built] [@nativescript/core/ui/styling/style-scope] external “@nativescript/core/ui/styling/style-scope” 42 bytes {bundle} [built] + 8 hidden modules Webpack compilation complete. Watching for file changes. Webpack build done! Project successfully prepared (android) Start sending initial files for device %H:%M:%S (84033bdf-d3d6-43a3-9857-621b7f558e03). Successfully sent initial files for device %H:%M:%S (84033bdf-d3d6-43a3-9857-621b7f558e03). LOG from device %H:%M:%S: com.tns.NativeScriptException: Error calling module function Error: Type AppRoutingModule does not have ‘ngModuleDef’ property. File: (file:///data/data/org.nativescript.preview/files/app/tns_modules/@angular/core/bundles/core.umd.js:1682:12)

StackTrace: ZoneAwareError(file:///data/data/org.nativescript.preview/files/app/tns_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:1298:33) at getNgModuleDef(file:///data/data/org.nativescript.preview/files/app/tns_modules/@angular/core/bundles/core.umd.js:1682:19) at (file:///data/data/org.nativescript.preview/files/app/tns_modules/@angular/core/bundles/core.umd.js:1513:31) at noSideEffects(file:///data/data/org.nativescript.preview/files/app/tns_modules/@angular/core/bundles/core.umd.js:1321:19) at ����setNgModuleScope(file:///data/data/org.nativescript.preview/files/app/tns_modules/@angular/core/bundles/core.umd.js:1512:16) at (file:///data/data/org.nativescript.preview/files/app/bundle.js:42:131) at ./app/app-routing.module.tns.ts(file:///data/data/org.nativescript.preview/files/app/bundle.js:42:339) at webpack_require(file:///data/data/org.nativescript.preview/files/app/runtime.js:817:30) at fn(file:///data/data/org.nativescript.preview/files/app/runtime.js:121:20) at ./app/app.module.tns.ts(file:///data/data/org.nativescript.preview/files/app/bundle.js:97:85) at webpack_require(file:///data/data/org.nativescript.preview/files/app/runtime.js:817:30) at fn(file:///data/data/org.nativescript.preview/files/app/runtime.js:121:20) at (file:///data/data/org.nativescript.preview/files/app/bundle.js:211:77) at ./main.tns.ts(file:///data/data/org.nativescript.preview/files/app/bundle.js:276:30) at webpack_require(file:///data/data/org.nativescript.preview/files/app/runtime.js:817:30) at checkDeferredModules(file:///data/data/org.nativescript.preview/files/app/runtime.js:44:23) at webpackJsonpCallback(file:///data/data/org.nativescript.preview/files/app/runtime.js:31:19) at (file:///data/data/org.nativescript.preview/files/app/bundle.js:2:57) at require(:1:266)

Error: Type AppRoutingModule does not have ‘ngModuleDef’ property. at com.tns.Runtime.runModule(Native Method) at com.tns.Runtime.runModule(Runtime.java:674) at com.tns.Runtime.run(Runtime.java:666) at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5448) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1564) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6186) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

To Reproduce generate a new shared project: ng new -c=@nativescript/schematics workspace --shared enter the project folder: cd workspace run any these commands: tns preview, npm run preview (with or without –no-hmr flag)

Expected behavior Run the project on the real device (preview)

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 4
  • Comments: 43 (3 by maintainers)

Most upvoted comments

Angular 11 is in it’s pre release state and there’s still no solution for this problem with NS preview app that generates for everyone who starts with NS coding with later Angular version. How long do we have to wait before this is fixed?

Having the same issue and waiting for the update…

@betosalvador preview needs app store updates which we’re working on to bring Angular 10 support to the {N} Preview app. We’ll ping back once latest updates have been approved and live on the store.

In meantime you can just use nsc debug android --no-hmr or nsc debug ios --no-hmr

Hi @NathanWalker, as mentioned above this issue has been asked several times, but this bug is reported since August and even after 4 months we don’t have solution or atleast some kind of way around. It would be nice if You could atleast provide some status update. Right now I am in bad situation. I need to update to angular 10 because one of our internal package is build on it and I need to use it in nativescript project but I cannot do it because of this bug.

Thank you for reply.

I have tried so many other options and finally moved to react native as I have not seen any proper attention on the issue.

Still no solution for this breaking bug. Time to abandon this sinking ship and move on for a more supported framework. It’s too bad, it had so much potential.

its been months since this issue is reported can one of the devs just release a statement please ? are you going to fix it or not ? if you are please just state the priority of this fix (low normal high ?). It won’t kill you to leave a comment saying we are not supporting nativescript anymore or something like that or just the truth.

Kind regards

@NathanWalker, please do something about the issue. Many people including me, are still waiting in this thread hoping for your answer as it is still open. Either close this or announce something brother.

any updates before we reach end of 2020? -same issue here.

I had the same issue i solve it by running the app in my physical device using : ns run android instead of running the app by ns preview To be able to run this command you need: (android configuration)

  • Android SDK
  • Java (jdk 12)
  • ADB

After installation of this things run ns doctor and you will see a message like this:

image

hope this will help you

@hartbrkr3399 Thanks for the reply

Kind regards

If you have Angular 10.x+, move to Angular 8.x guys. That’s the only way now.

On Mon, 1 Mar, 2021, 11:12 pm martijnmichel, notifications@github.com wrote:

same

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NativeScript/nativescript-schematics/issues/290#issuecomment-788137905, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANF2TZ7JOBA5EUM7ZCKHMPLTBPGWXANCNFSM4PR2HLMA .

I had the same issue i solve it by running the app in my physical device using : ns run android instead of running the app by ns preview To be able to run this command you need: (android configuration)

  • Android SDK
  • Java (jdk 12)
  • ADB

After installation of this things run ns doctor and you will see a message like this: image hope this will help you

This doesn’t help, what are you on about?

This actually does work …

  • Run the advanced setup. In my case linux, so select your OS here
  • run tns doctor if all green go to next step
  • Plug in mobile device
  • run ns run android

Let the magic happen

We recommend using xplat for code sharing. It’s better supported, more scalable and will lead you to better results. It’s been available as long as schematics here but supports angular versions faster. https://nstudio.io/xplat/getting-started

xplat uses Nrwl Nx which provides better tooling all around for effective and massive code sharing.

That being said schematics here have been updated to version 11 when angular 11 was released. These commands have been known to work just fine: https://gist.github.com/NathanWalker/266f597de1a93314bec9efa6d21c15a2

I got the same error, I am just started new project using ng new --collection=@nativescript/schematics test-project --shared, fix some errors in polyfills.ts and tsconfig.json with the help of stackowerflow and github, but this error is not solved for me. I did nothing but starting new project… now I will think twice before using nativescript for future projects, If I got throubles at the start of my project what will it be in future.

Same, I had to download an early version of tns in order to make it work. Ended up installing version 6.4.1 and from there I was able to run it