gpt4 book ai didi

angular - NativeScript + Angular : Code Sharing Project

转载 作者:搜寻专家 更新时间:2023-10-30 21:57:07 24 4
gpt4 key购买 nike

我按照 Nativescript 的步骤创建了一个新的代码共享项目 here我想使用 sass。我尝试了具有 NatievScript 主题的主题和不具有 NatievScript 主题的主题:

ng new -c=@nativescript/schematics no-theme-project --shared --no-theme

ng new -c=@nativescript/schematics sass-no-theme-project --shared --style=scss --no-theme

对于这篇文章,我选择了无主题。完成创建新项目后,文件夹如下所示:

enter image description here

Desktop/TestProjects/sass-no-theme-project 中,我安装了节点模块:

npm install

运行 ng serve --o 时,应用程序会按预期在浏览器中构建和加载。对于 NativeScript 移动版,但对于 Android(尚未测试 iOS),应用程序会因错误而崩溃。我已经尝试过 tns run android 以及使用 NativeScript SideKick 进行构建,但是它们最终得到了相同的结果。我也尝试过本地和云构建。

使用的设备:

物理三星 A5:不是模拟器

日志中移动设备上的错误:

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6065)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
at com.tns.Module.bootstrapApp(Module.java:311)
at com.tns.Runtime.run(Runtime.java:544)
at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6062)
... 8 more
Caused by: com.tns.NativeScriptException: Failed to find module: "./", relative to: app//
at com.tns.Module.resolvePathHelper(Module.java:146)
at com.tns.Module.bootstrapApp(Module.java:309)
... 12 more

登录命令行和 NativeScript 客户端

[18-11-10 17:43:53.724] (CLI) [./main.ns.ts] 1.22 KiB {bundle} [built]
[18-11-10 17:43:53.724] (CLI) [./package.json] 123 bytes {bundle} [optional] [built]
[18-11-10 17:43:53.724] (CLI) + 403 hidden modules
[18-11-10 17:43:53.724] (CLI) ERROR in Patterns must be a string or an array of strings
[18-11-10 17:43:53.724] (CLI) Webpack compilation complete.
[18-11-10 17:43:53.724] (CLI) Executing webpack failed with exit code 2.
[18-11-10 17:43:53.724] (CLI) # tns build android
[18-11-10 17:43:53.724] (CLI) ### Description
[18-11-10 17:43:53.724] (CLI) clean-webpack-plugin: /mnt/storage/builds/_/1bfec9e7b462a1843535f909d892c70d2010e1cf/5.0.0/5.0.0/no-sass-project/platforms/android/app/src/main/assets/app/**/* has been removed.
[18-11-10 17:43:53.724] (CLI) Executing webpack failed with exit code 2.
[18-11-10 17:43:53.724] (CLI) bc_GgX4lpDXQFHYT4ydmJ
[18-11-10 17:43:56.917] (CLI) Unable to apply changes on device: 5210ffc964ca44f3. Error is: Build failed..
[18-11-10 17:43:56.920] Error detected during LiveSync on 5210ffc964ca44f3 for C:\Users\userName\Desktop\no-sass-project. Error: Build failed.
[18-11-10 17:43:56.925] (CLI) Executing after-watch hook from C:\Users\userName\Desktop\no-sass-project\hooks\after-watch\nativescript-dev-sass.js
[18-11-10 17:43:56.925] (CLI) Executing after-watch hook from C:\Users\userName\Desktop\no-sass-project\hooks\after-watch\nativescript-dev-typescript.js
[18-11-10 17:43:56.925] (CLI) Executing after-watch hook from C:\Users\userName\Desktop\no-sass-project\hooks\after-watch\nativescript-dev-webpack.js
[18-11-10 17:43:56.925] (CLI) Stopping webpack watch

使用 Nativescript 和 Angular 为我创建了一个空白的新项目,我认为它应该是一个可以在 Web、iOS 和 Android 中运行的 HelloWorld 项目。

更新

我尝试遵循故障排除指南 here例如重新安装 JDK 8 但是问题仍然存在。我让它运行了一次,它失败了,大约 4-10 分钟后它重建并开始工作。从那以后,我无法让它再次工作。这让我相信在某处可能存在配置问题,例如 tsconfig json 文件。看了一下它们,它们似乎还不错。

最佳答案

当您构建代码共享项目时,您应该使用 --bundle 标志。所以你的命令应该是:

tns 运行 android --bundletns 运行 ios --bundle

如果您一直忘记 --bundle 标志,那么您可以使用 package.json 中提供的脚本并运行:npm run androidnpm run ios

此外,如果您的项目使用 TypeScript 2.7,那么您可能需要将其更新到 2.8

附带说明:在代码共享项目中您不需要 moduleId,因为 webpack 会为您处理这件事。

关于angular - NativeScript + Angular : Code Sharing Project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53196685/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com