NativeScript + Angular - New project Error on Preview: Type AppRoutingModule does not have 'ngModuleDef' property

2.3k Views Asked by At

I installed everything need. The project is the generated one. I don't even have made changes but when I try to preview it and scan the qrcode, I got an Error "Type AppRoutingModule does not have 'ngModuleDef' property".

  • npm 6.14.6
  • nodejs LTS v12.18.3
  • Angular cli 10.1.1 which I use to run an angular project
  • NativeScript CLI v7.0.7

I always end up having this error:

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:49:131)
    at ./app/app-routing.module.ts(file:///data/data/org.nativescript.preview/files/app/bundle.js:49: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.ts(file:///data/data/org.nativescript.preview/files/app/bundle.js:103:77)
    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:306:73)
    at ./main.ts(file:///data/data/org.nativescript.preview/files/app/bundle.js:372: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:1155)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5949)
    at android.app.ActivityThread.access$1200(ActivityThread.java:200)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:201)
    at android.app.ActivityThread.main(ActivityThread.java:6810)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)```

Thank you for your help!
2

There are 2 best solutions below

0
Manuel Moreno On

That works for me:

  1. Run the advanced setup. Full setup
  2. run tns doctor if all green go to next step.
  3. Plug in mobile device.
  4. run ns run android

Let the magic happen

GitHub solution

0
nanDeszka On

First I did full setup then I uninstalled JDK 18 and then ns run android worked.