webpack - nativescript 6.0.1 无法运行/准备 android 应用程序
问题描述
我最近更新了tns
到版本 6.0.1,我读过它总是用于webpack
构建项目。
我tns migrate
在我的项目中使用,将我的本地插件更新为 AndroidX(使用 Android Studio 重构选项),生成我的.aar
文件并tns migrate
在我的插件演示项目中使用。之后,当我尝试演示项目时,它确实有效。我的问题出在我的主项目上:我将新插件添加到我的项目中,删除并添加了 android 平台(tns-android
版本 6.0.0),但是当我运行tns prepare android
或tns run android
我收到有关我的插件的错误时:
ERROR in /workspace/workspace-nativescript/nativescript-my-plugin/src/my-plugin.ts
Module build failed (from ../node_modules/@ngtools/webpack/src/index.js):
Error: /workspace/workspace-nativescript/nativescript-my-plugin/src/my-plugin.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at NativeScriptAngularCompilerPlugin.getCompiledFile (/workspace/workspace-nativescript/my-project/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:844:23)
at NativeScriptAngularCompilerPlugin.getCompiledFile (/workspace/workspace-nativescript/my-project/node_modules/nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin.js:28:26)
at plugin.done.then (/workspace/workspace-nativescript/my-project/node_modules/@ngtools/webpack/src/loader.js:41:31)
at process._tickCallback (internal/process/next_tick.js:68:7)
我之前正在阅读关于 的类似问题nativescript-dev-webpack
,但我有 1.0.1 版本,tns migrate
这是最后一个版本。这也是我的tnsconfig.json
文件(我也有一个nsconfig.json
文件,但它是空的):
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"lib": [
"es6",
"dom",
"es2015.iterable"
],
"baseUrl": ".",
"paths": {
"~/*": [
"app/*"
],
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
]
}
},
"exclude": [
"node_modules",
"platforms"
]
}
解决方案
很可能你已经在你的主要 Angular 应用程序中链接了一个 TypeScript 插件(而不是从 tgz 安装它)。
我想您的插件已经从官方插件种子创建,这就是正确配置演示应用程序的原因,或者您正在运行 TypeScript 演示,而不是 Angular 演示。
当你想在你的 Angular 应用程序中链接一个插件时,你必须包含它的 TypeScript 文件(据我所知,这是AngularCompilerPlugin
. 如果您从插件种子 ( tns plugin create
) 开始,这已经在您的演示应用程序中进行了配置。
换句话说,tsconfig.json
在您的主应用程序 ( /workspace/workspace-nativescript/my-project/tsconfig.json
) 中打开并将其内容替换为:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"lib": [
"es6",
"dom",
"es2015.iterable"
],
"baseUrl": ".",
"paths": {
"~/*": [
"app/*"
],
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
]
}
},
"include": [
"../nativescript-my-plugin/src",
"**/*"
],
"exclude": [
"../nativescript-my-plugin/src/node_modules",
"node_modules",
"platforms"
]
}
推荐阅读
- parameters - Cucumber 并行执行 - 多数据的单一场景
- android - 如何使用警报对话框检查所有复选框?
- angular - 从反应形式 valueChanges 中删除空对象值
- bash - 将 Bash 脚本转换为 crontab 的行为不同
- java - 如何更改抽屉标题?
- c - C编程中“返回语句”可以带多少参数?
- wamp - Wamp 错误-您无权访问此服务器上的 /。通过 IP 访问
- ios - Swift - “预计解码数组
而是找到了一本字典。” - php - 如何将 phpspreadsheet-object 更改为 html-object
- angular - 带有变量的 Apollo 角度查询无法解析