使用 `--prod` 构建的离子滚动头包问题(请添加 @NgModule 注释。)
ionic scrolling header package issue in`building using `--prod` ( Please add a @NgModule annotation.)
git 仓库中有一个包
https://github.com/keephacking/ionic-scrolling-header
它具备与 aot 兼容的所有条件。但是在使用
构建我的应用程序时
ionic build --prod
命令,aot 构建失败,错误如下所示。
[18:02:48] ngc started ...
[18:02:57] typescript error
Unexpected value 'ScrollingHeaderModule in
xxx/node_modules/ionic-scrolling-header/scrolling-header.module.d.ts' imported by the
module 'xxxModule in xxx/xxx.module.ts'. Please add a @NgModule
annotation.
Error: The Angular AoT build failed. See the issues above
at xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
at step (xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
at Object.next (xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
at fulfilled (xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
[18:02:57] copy finished in 10.69 s
我在 Package.json
中的依赖项
{
"dependencies": {
"@angular/common": "5.2.0",
"@angular/compiler": "5.2.0",
"@angular/compiler-cli": "5.2.0",
"@angular/core": "5.2.0",
"@angular/forms": "5.2.0",
"@angular/http": "5.2.0",
"@angular/platform-browser": "5.2.0",
"@angular/platform-browser-dynamic": "5.2.0",
"@ionic-native/core": "4.4.2",
"@ionic/storage": "2.1.3",
"es6-promise-plugin": "^4.1.1",
"firebase": "^4.8.0",
"ionic-angular": "3.9.2",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"promise-polyfill": "^7.0.0",
"rxjs": "5.5.6",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18"
},
"devDependencies": {
"@angular/cli": "^1.6.3",
"@ionic/app-scripts": "3.1.7",
"typescript": "2.6.2"
}
}
非常想知道那个包裹里少了什么。
谢谢
当我的 tsconfig.json 没有发出声明文件时,我遇到了这个错误。
请确保在构建 ScrollingHeaderModule
的代码库中的 tsconfig.json 中包含以下内容:
"declaration": true,
我按照以下步骤操作,对我有用,希望对您有所帮助
第 1 步:安装 npm install ionic-scrolling-header --sav-dev
第 2 步:打开您的 home.moduel.ts
文件并导入此 import {ScrollingHeaderModule} from 'ionic-scrolling-header';
并且不要忘记将其添加到您的导入
中
imports: [
ScrollingHeaderModule,
IonicPageModule.forChild(HomePage),
],
第 3 步:在您的 home.ts 文件中添加此 @ViewChild(Content) content: Content;
第 4 步:在您的 home.html 页面中添加此 <ion-header [scrollingHeader]='content'>
有关详细信息,请查看此 link
我已经按照以下步骤修复了它:
0-Download project from author repository
1-Rename "src" folder to "ionic-scrolling-header", and copy to your directive(folder)
2-Create a directive folder inside src (folder)
3-Change import in your app.module.ts, as you can see on my print:
screenshot
该问题已在最新版本的 ionic-scrolling-header 包中修复。
npm install ionic-scrolling-header@latest
会修复它。
Ionic 6.7.0,Corodova 0.14.0
遇到了类似的问题,尝试了一切....后来发现我在文件 directives.module.ts[=17= 中缺少 Class 'XYZ' 的导入].所以在该文件中添加了 import 语句,也在 NgModule 声明中。
import {ParallaxHeader} from './parallax-header/parallax-header';
@NgModule({
declarations: [ParallaxHeader],
imports: [],
exports: [ParallaxHeader] })
git 仓库中有一个包
https://github.com/keephacking/ionic-scrolling-header
它具备与 aot 兼容的所有条件。但是在使用
构建我的应用程序时ionic build --prod
命令,aot 构建失败,错误如下所示。
[18:02:48] ngc started ...
[18:02:57] typescript error
Unexpected value 'ScrollingHeaderModule in
xxx/node_modules/ionic-scrolling-header/scrolling-header.module.d.ts' imported by the
module 'xxxModule in xxx/xxx.module.ts'. Please add a @NgModule
annotation.
Error: The Angular AoT build failed. See the issues above
at xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
at step (xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
at Object.next (xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
at fulfilled (xxx\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
[18:02:57] copy finished in 10.69 s
我在 Package.json
中的依赖项{
"dependencies": {
"@angular/common": "5.2.0",
"@angular/compiler": "5.2.0",
"@angular/compiler-cli": "5.2.0",
"@angular/core": "5.2.0",
"@angular/forms": "5.2.0",
"@angular/http": "5.2.0",
"@angular/platform-browser": "5.2.0",
"@angular/platform-browser-dynamic": "5.2.0",
"@ionic-native/core": "4.4.2",
"@ionic/storage": "2.1.3",
"es6-promise-plugin": "^4.1.1",
"firebase": "^4.8.0",
"ionic-angular": "3.9.2",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"promise-polyfill": "^7.0.0",
"rxjs": "5.5.6",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18"
},
"devDependencies": {
"@angular/cli": "^1.6.3",
"@ionic/app-scripts": "3.1.7",
"typescript": "2.6.2"
}
}
非常想知道那个包裹里少了什么。
谢谢
当我的 tsconfig.json 没有发出声明文件时,我遇到了这个错误。
请确保在构建 ScrollingHeaderModule
的代码库中的 tsconfig.json 中包含以下内容:
"declaration": true,
我按照以下步骤操作,对我有用,希望对您有所帮助
第 1 步:安装 npm install ionic-scrolling-header --sav-dev
第 2 步:打开您的 home.moduel.ts
文件并导入此 import {ScrollingHeaderModule} from 'ionic-scrolling-header';
并且不要忘记将其添加到您的导入
imports: [
ScrollingHeaderModule,
IonicPageModule.forChild(HomePage),
],
第 3 步:在您的 home.ts 文件中添加此 @ViewChild(Content) content: Content;
第 4 步:在您的 home.html 页面中添加此 <ion-header [scrollingHeader]='content'>
有关详细信息,请查看此 link
我已经按照以下步骤修复了它:
0-Download project from author repository
1-Rename "src" folder to "ionic-scrolling-header", and copy to your directive(folder)
2-Create a directive folder inside src (folder)
3-Change import in your app.module.ts, as you can see on my print:
screenshot
该问题已在最新版本的 ionic-scrolling-header 包中修复。
npm install ionic-scrolling-header@latest
会修复它。
Ionic 6.7.0,Corodova 0.14.0
遇到了类似的问题,尝试了一切....后来发现我在文件 directives.module.ts[=17= 中缺少 Class 'XYZ' 的导入].所以在该文件中添加了 import 语句,也在 NgModule 声明中。
import {ParallaxHeader} from './parallax-header/parallax-header';
@NgModule({
declarations: [ParallaxHeader],
imports: [],
exports: [ParallaxHeader] })