问题标签 [nativescript-schematics]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
257 浏览

angular - NativeScript/Angular - 如何在两个应用程序之间共享导入?

我不敢相信互联网上和 NativeScript 官方文档中都没有提到这一点。

您如何在 Web 应用程序和本机应用程序之间共享导入?

在本机环境中运行应用程序时,以下内容有效npm run android

但是,如果我用 ng serve 运行它以在浏览器中运行我的应用程序,它会说

找不到模块“~/app/shared/constants/app.constant”。

如果我尝试在 tsconfig.json 中定义自定义路径:

然后做:

运行这个可以ng serve工作,但猜猜看,当使用 npm run android 运行应用程序时它不起作用。

您无法检查您在哪个平台上运行并决定导入的外观,因为由于同一文件在同一个文件中被导入两次,您会收到“重复导入”错误。

在我发疯之前有人可以帮助我吗?

编辑:

我运行了这个命令来生成项目:

ng new -c=@nativescript/schematics foo-project --shared --style=scss

如此处所述。

这是tsconfig.json

0 投票
2 回答
2327 浏览

angular - NativeScript + Angular: Code Sharing Project

I followed the Nativescript steps for creating a new code sharing project here and I would like to use sass. I tried both for ones that have the NatievScript theme as well as the one that does not:

or

For this Post I chose No Theme. When it finishes creating a new project the folder is as shown:

enter image description here

Inside Desktop/TestProjects/sass-no-theme-project I install the node modules:

When running ng serve --o the application builds and loads up as expected in the browser. For NativeScript mobile however for Android (have not tested iOS yet) the application crashes with an error. I have tried both tns run android as well as using the NativeScript SideKick to build however they end up with the same results. I have also tried local and cloud builds.

Device Used:

Physical Samsung A5: Not emulator

Error On Mobile Device In Logs:

Logs In Command Line and NativeScript Client

With Nativescript and Angular creating a blank new project for me I would assume it is suppose to be a HelloWorld project that works in Web, iOS, and Android right out of the gate.

UPDATE

I tried following the troubleshoot guide here such as reinstalling JDK 8 and that however the problem persists. I got it to run once, it failed and after about 4-10 minutes it rebuilt and was working. Since then I can not get it to work a second time. This leads to me believe there maybe a configuration issues somewhere such as the tsconfig json files. Taken a look in them and they seem to be fine.

0 投票
2 回答
499 浏览

angular - NativeScript Schematics - 多次调用单例服务构造函数

在 nativescript-schematics 代码共享项目中多次调用单例服务构造函数。这是我的 package.json 中的一些重要依赖版本:

"tns-android": {"version": "5.0.0"} "@angular/core": "~7.1.0", "nativescript-angular": "^7.1.0", "tns-core-modules": "^5.0.5", "@nativescript/schematics": "^0.4.0", "nativescript-dev-typescript": "^0.7.8", "nativescript-dev-webpack": "^0.17.0", "typescript": "~3.1.1"

我已经尝试providedIn: 'root'Angular 官方文档中进行描述并检查了 singletonInstance 。构造函数被多次调用。

我需要使用forRoot吗,因为我们有 app.module.ts 和 app.module.tns.ts ?

0 投票
1 回答
249 浏览

angular - 如何将现有的 NativeScript Angular 项目转换为代码共享项目

所有可用的教程都讨论了将 Angular Web 应用程序转换为代码共享 Nativescript 项目。我想做相反的事情。

我几乎完成了使用 Nativescript 编写移动应用程序的代码,现在我想通过两者之间的代码共享来制作 Web 应用程序。

0 投票
1 回答
276 浏览

angular - 为什么nativescript 如此频繁地使用NO_ERRORS_SCHEMA?

我注意到 NO_ERRORS_SCHEMA 经常被 nativescript 模块使用,包括 nativescript-schematics 以及 nativescript 与 Angular 的示例。但是我只是想知道为什么会这样?

我想对此有一个很好的解释,我只是还没有那么喜欢 nativescript。通常我会说应该避免使用 NO_ERRORS_SCHEMA,因为它会使你的调试更加困难,所以我很好奇为什么到处都使用它。

例子:

https://docs.nativescript.org/performance-optimizations/lazy-loading

https://github.com/NativeScript/nativescript-schematics/blob/master/src/generate/module/index.ts#L327

https://github.com/NativeScript/nativescript-schematics/blob/master/src/generate/module/index_spec.ts#L72

0 投票
1 回答
543 浏览

nativescript - 最新的 NativeScript + Angular 坏了

我将 nativeScript、@angular/cli 和 @nativescript/schematics 更新为最新的稳定版本。生成了一个新项目:

ng 新端口 --collection=@nativescript/schematics --shared --style=scss --prefix=port

其次是

tns 运行 ios --bundle

错误:

0 投票
1 回答
279 浏览

android - 我的 gradlew.bat 在 tns build android 上一直失败

因此,过去几个月我一直在使用 Angular-Nativescript,并且有一个项目都使用 Angular 9。短暂休息后,我开始在另一台机器上工作,该机器说项目正在开发,但不记得它是在 Angular 7 上. 我运行脚本来升级 Angular,它直接升级到版本 10,这是我的问题开始的地方。在所有安装、升级、迁移、下载和重新安装之后,我能够生成、运行和提供 Angular 组件,但我无法构建 Nativescript。tns build android 命令总是运行到 55% 然后抛出错误

命令 gradlew.bat 失败,退出代码为 1

我不知道在哪里可以找到更详细的信息。我尝试在批处理文件中回显不同的步骤,但不知道是什么问题。如果我没有使用正确的术语,我深表歉意,因为我对前端世界还很陌生。

一些支持信息......我已经到了在我的机器上使用模拟器的地步。我安装了运行模拟器的 Android Studio。因此,当我运行 tns 设备时,我可以看到一个示例,如随附的屏幕截图所示。据我所知,应该创建一个 apk 文件并将其传输到模拟器,但我不知道在哪里查看文件是否正在创建但只是没有被传输。

如果有人知道这是什么,我们将不胜感激获得正确的修复错误。

控制台文本是

tns 信息是

我在 Windows 10 笔记本电脑上 设备已被识别

0 投票
2 回答
226 浏览

json - NativeScript 找不到模块“@nativescript/schematics”

当我让 tns 生成组件电影时,我得到终端日志:找不到模块“@nativescript/schematics”。

我尝试了https://github.com/NativeScript/nativescript-schematics/issues/130的解决方案,但下一条终端消息是:

包.json:

ng--版本

0 投票
0 回答
60 浏览

angular - 将 nativescript 原理图添加到 Angular 项目后出错

使用此 npm install --global @nativescript/schematics 和 ng add @nativescript/schematics 将 nativescripts 添加到现有的 Angular 应用程序

在错误 TS6053 中遇到错误错误:找不到文件“C:[路径]/src/src/main.ts”。

错误 TS6053:找不到文件“C:[path]/src/src/polyfills.ts”。

然后我按照这个链接来解决它https://stackoverflow.com/a/58623108/14326477

但随后又出现了不同的错误,附上下面的屏幕截图

图片附在此处。构建时出错

./src/app/components/refund/refund.module.ts 中的错误模块构建失败(来自 ./node_modules/@ngtools/webpack/src/index.js):错误:C:\Users[path]\Client\ TypeScript 编译中缺少 src\app\components\refund\refund.module.ts。请通过 'files' 或 'include' 属性确保它在您的 tsconfig 中。在 AngularCompilerPlugin.getCompiledFile (C:\Users[path][\Client\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:752:23) 在 plugin.done.then (C:\Users[path]\Client\node_modules @ngtools\webpack\src\loader.js:41:31) 在 process._tickCallback (internal/process/next_tick.js:68:7)

你们能帮忙吗?

0 投票
0 回答
181 浏览

nativescript - 在 Nativescript 中创建新的代码共享项目会导致 tslint 和 tslint-rules 的依赖错误

我正在开发一个需要转换为原生 Android 代码的 Nativescript 项目。我没有多少 Nativescript 经验,所以我正在做一个关于“代码共享”的教程。

https://docs.nativescript.org/code-sharing/creating-a-new-project

我已经完成了设置并安装了所有依赖项。我可以通过以下方式确认tns doctor

然后我运行了两个提到的命令:

然后是第二个,但问题似乎已经在第一个命令中:

任何帮助将不胜感激。