请在 Angular 5 上添加 @ngModule 注释错误
Posted
技术标签:
【中文标题】请在 Angular 5 上添加 @ngModule 注释错误【英文标题】:Please add @ngModule Annotation Error on Angular 5 【发布时间】:2018-07-23 10:29:24 【问题描述】:我正在使用 selectsearchable 包,在添加了它在网络上也可以使用ionic cordova build android
后正常工作。当试图在ionic cordova build android --prod
中编译时,它会抛出一个错误
Please add @Ngmodule Annotation
模块导入的意外值“D:/MdAshiff/Ionic/ionic/node_modules/ionic-select-searchable/source/select-searchable.module.d.ts 中的 SelectSearchableModule” 'D 中的 AppModule:/MdAshiff/Ionic/ionic/src/app/app.module.ts'。请添加一个 @NgModule 注释。
app.module.ts
import NgModule, ErrorHandler from '@angular/core';
import IonicApp, IonicModule, IonicErrorHandler, NavController from 'ionic-angular';
import Geolocation from '@ionic-native/geolocation';
import AppMinimize from '@ionic-native/app-minimize';
import OpenNativeSettings from '@ionic-native/open-native-settings';
import MyApp from './app.component';
import Ionic2RatingModule from 'ionic2-rating';
import NativeStorage from '@ionic-native/native-storage';
import SplashScreen from '@ionic-native/splash-screen'
import CallNumber from '@ionic-native/call-number';
import Push, PushObject, PushOptions from '@ionic-native/push';
import LocalNotifications from '@ionic-native/local-notifications';
import Diagnostic from '@ionic-native/diagnostic';
import HomePage from '../pages/home/home';
import BrowserModule from '@angular/platform-browser';
import HttpModule from '@angular/http';
import SelectSearchableModule from 'ionic-select-searchable';
@NgModule(
declarations: [
MyApp,
HomePage
],
imports: [
IonicModule.forRoot(MyApp),
Ionic2RatingModule,
BrowserModule,
HttpModule,
SelectSearchableModule
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
loginPage,
dashboardPage,
ActivitiesPage,
InvoicePage,
feedbackPage,
samplePage,
locationUpdatePage,
scopeofworkPage,
SchedulePage,
waypointPage
],
providers:
[
Geolocation,
NativeStorage,
OpenNativeSettings,
CallNumber,
Push,
LocalNotifications,
Diagnostic,
provide: ErrorHandler, useClass: IonicErrorHandler
,
SplashScreen,
AppMinimize ]
)
export class AppModule
tsconfig.json
"compilerOptions":
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5"
,
"angularCompilerOptions":
"skipTemplateCodegen": true,
"skipMetadataEmit": false,
"strictMetadataEmit": true,
"annotationsAs": "decorators"
,
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom":
"rewriteTsconfig": false
,
"paths":
"@angular/*": [
"../node_modules/@angular/*"
]
package.json
**
"name": "Md",
"author": "",
"homepage": "",
"private": true,
"scripts":
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve",
"watch": "ionic-app-scripts watch"
,
"dependencies":
"@angular/common": "5.0.3",
"@angular/compiler": "5.0.3",
"@angular/compiler-cli": "5.0.3",
"@angular/core": "5.0.3",
"@angular/forms": "5.0.3",
"@angular/http": "5.0.3",
"@angular/platform-browser": "5.0.3",
"@angular/platform-browser-dynamic": "5.0.3",
"@ionic-native/app-minimize": "^4.5.3",
"@ionic-native/call-number": "^4.5.3",
"@ionic-native/core": "4.4.0",
"@ionic-native/diagnostic": "^4.5.3",
"@ionic-native/fcm": "^4.5.3",
"@ionic-native/geolocation": "^4.5.3",
"@ionic-native/local-notifications": "^4.5.3",
"@ionic-native/native-storage": "^4.5.3",
"@ionic-native/network": "^4.5.3",
"@ionic-native/open-native-settings": "^4.5.3",
"@ionic-native/push": "^4.5.3",
"@ionic-native/secure-storage": "^4.5.3",
"@ionic-native/splash-screen": "^4.5.3",
"@ionic/storage": "2.1.3",
"call-number": "^1.0.1",
"cordova-android": "6.3.0",
"cordova-ios": "4.2.0",
"cordova-open-native-settings": "^1.5.0",
"cordova-plugin-app-event": "~1.2.1",
"cordova-plugin-appminimize": "^1.0.0",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-console": "1.0.5",
"cordova-plugin-crosswalk-webview": "~2.4.0",
"cordova-plugin-device": "1.1.4",
"cordova-plugin-geolocation": "~2.4.3",
"cordova-plugin-nativestorage": "~2.2.2",
"cordova-plugin-network-information": "^1.3.4",
"cordova-plugin-splashscreen": "~4.0.1",
"cordova-plugin-statusbar": "2.2.1",
"cordova-plugin-whitelist": "1.3.1",
"cordova-windows": "4.4.2",
"cordova.plugins.diagnostic": "^3.9.2",
"de.appplant.cordova.plugin.local-notification": "^0.8.5",
"ionic-angular": "3.9.2",
"ionic-native": "2.4.1",
"ionic-plugin-keyboard": "~2.2.1",
"ionic-select-searchable": "^1.0.2",
"ionic2-rating": "^1.2.2",
"ionicons": "3.0.0",
"mx.ferreyra.callnumber": "~0.0.2",
"phonegap-plugin-push": "~2.1.2",
"rxjs": "5.5.2",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18"
,
"devDependencies":
"@ionic/app-scripts": "3.1.8",
"typescript": "2.4.2"
,
"description": "Ionic2Blank: An Ionic project",
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": [],
"-vs-binding":
"BeforeBuild": [
"ionic:build"
]
,
"cordova":
"platforms": [
"ios",
"windows",
"android"
],
"plugins":
"cordova-plugin-console": ,
"cordova-plugin-device": ,
"cordova-plugin-geolocation": ,
"cordova-plugin-nativestorage": ,
"cordova-plugin-splashscreen": ,
"cordova-plugin-statusbar": ,
"cordova-plugin-whitelist": ,
"ionic-plugin-keyboard": ,
"cordova-plugin-network-information": ,
"cordova-open-native-settings": ,
"mx.ferreyra.callnumber": ,
"de.appplant.cordova.plugin.local-notification": ,
"cordova-plugin-compat": ,
"cordova-plugin-app-event": ,
"cordova.plugins.diagnostic": ,
"cordova-plugin-crosswalk-webview":
"XWALK_VERSION": "23+",
"XWALK_LITEVERSION": "xwalk_core_library_canary:17+",
"XWALK_COMMANDLINE": "--disable-pull-to-refresh-effect",
"XWALK_MODE": "embedded",
"XWALK_MULTIPLEAPK": "true"
,
"phonegap-plugin-push":
"SENDER_ID": "XXXXXXXXXXX"
,
"cordova-plugin-appminimize":
**
我已经经历了各种解决方案,但有些地方我错过了。下面添加了使用的版本的详细信息
离子 3 科尔多瓦安卓:6.3.0 科尔多瓦:7.1.0
其余版本在 package.json 文件中。有什么解决办法吗?
【问题讨论】:
那么 SelectSearchableModule 是什么?图书馆? 是的,是从npmSelectSearchable获取的库 模拟器能用吗? 没有 --prod 标志它正在工作 可能会在 github 中引发问题? github.com/eakoriakin/ionic-select-searchable 或尝试演示应用程序github.com/eakoriakin/ionic-select-searchable-demo 【参考方案1】:作者已修复此问题:
将库更新到 1.0.8
npm install ionic-select-searchable@1.0.8
https://github.com/eakoriakin/ionic-select-searchable-demo
【讨论】:
以上是关于请在 Angular 5 上添加 @ngModule 注释错误的主要内容,如果未能解决你的问题,请参考以下文章
Angular 4:未找到组件工厂,您是不是将其添加到 @NgModule.entryComponents?
Angular2 材质对话框有问题 - 您是不是将其添加到 @NgModule.entryComponents?
Angular Schematics - 将库添加到 NgModule 导入
你把它添加到@NgModule.entryComponents 了吗?
模块“AppModule”导入的意外值“DataTablesModule”。请添加@NgModule 注释
模块'DynamicTestModule'导入的意外值'DecoratorFactory'。请添加@NgModule注释