angular - NativeScript + Angular - 预览中的新项目错误 : Type AppRoutingModule does not have 'ngModuleDef' property

标签 angular nativescript preview generated

我安装了所有需要的东西。该项目是生成的。我什至没有进行更改,但是当我尝试预览它并扫描 qrcode 时,出现错误“Type AppRoutingModule 没有 'ngModuleDef' 属性”。

  • npm 6.14.6
  • nodejs LTS v12.18.3
  • 我用来运行 Angular 项目的 Angular cli 10.1.1
  • NativeScript CLI v7.0.7

  • 我总是最终遇到这个错误:
    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!
    

    最佳答案

    这对我行得通:

  • 运行高级设置。 Full setup
  • 如果全部为绿色,请运行 tns doctor 进入下一步。
  • 插入移动设备。
  • 运行 ns 运行 android

  • 让魔法发生
    GitHub solution

    关于angular - NativeScript + Angular - 预览中的新项目错误 : Type AppRoutingModule does not have 'ngModuleDef' property,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63842305/

    相关文章:

    javascript - 在 Angular2 应用程序中使用字符串插值从数组中提取值

    angular - 来自 Angular Material 的 MatDialog 对话框没有关闭

    ios - Nativescript:在设备中启动 iOS 应用程序时崩溃

    android - 我的 Android 设备无法使用 tns 预览扫描 CLI 中生成的二维码

    grails elfinder 插件 : preview does not work

    javascript - angular2 在具有自定义可序列化对象的后台线程中工作

    Angular 2 : Component Interaction, 可选输入参数

    angular - 如何将 angular 2 组件创建到 Nativescript 应用程序中?

    ios - AVCaptureSession VS UIImagePickerController 相机预览

    delphi - 使用 Delphi 打开对话框的自定义预览