nativescript 6.0.1 无法 run/prepare android 应用
nativescript 6.0.1 can't run/prepare android application
我最近将 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
的类似问题,但我有来自 tns migrate
的 1.0.1 版本,这是最后一个。这也是我的 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"
]
}
很可能您已经 link在主 Angular 应用程序中安装了 TypeScript 插件(而不是从 tgz 安装它)。
我想你的插件已经从官方插件种子创建,这就是演示应用程序正确配置的原因,或者你是 运行 TypeScript 演示,而不是 Angular。
当您想在 Angular 应用程序中 link 一个插件时,您必须包含它的 TypeScript 文件(据我所知,这是 AngularCompilerPlugin
的限制) .如果您从插件种子 (tns plugin create
) 开始,这已经在您的演示应用程序中配置。
换句话说,在您的主应用程序 (/workspace/workspace-nativescript/my-project/tsconfig.json
) 中打开 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"
]
}
我最近将 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
的类似问题,但我有来自 tns migrate
的 1.0.1 版本,这是最后一个。这也是我的 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"
]
}
很可能您已经 link在主 Angular 应用程序中安装了 TypeScript 插件(而不是从 tgz 安装它)。
我想你的插件已经从官方插件种子创建,这就是演示应用程序正确配置的原因,或者你是 运行 TypeScript 演示,而不是 Angular。
当您想在 Angular 应用程序中 link 一个插件时,您必须包含它的 TypeScript 文件(据我所知,这是 AngularCompilerPlugin
的限制) .如果您从插件种子 (tns plugin create
) 开始,这已经在您的演示应用程序中配置。
换句话说,在您的主应用程序 (/workspace/workspace-nativescript/my-project/tsconfig.json
) 中打开 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"
]
}