Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic cordova build Type 'ModuleWithProviders' is not generic

Hi I'm not very experienced with Angular and couldn't find a solution - I'm working on an Ionic Cordova project, and I wanted to update the Android API level. After that, I wasn't able to build my code with the command

ionic cordova build --release android

> ionic-app-scripts.cmd build --target cordova --platform android
[14:39:13]  ionic-app-scripts 3.2.4
[14:39:13]  build dev started ...
[14:39:13]  clean started ...
[14:39:13]  clean finished in 18 ms
[14:39:13]  copy started ...
[14:39:13]  deeplinks started ...
[14:39:13]  deeplinks finished in 337 ms
[14:39:13]  transpile started ...
[14:39:20]  typescript: {PROJECT_ROOT}/node_modules/@ionic/storage/index.d.ts, line: 5
            Type 'ModuleWithProviders' is not generic.

       L4:  export declare class IonicStorageModule {
       L5:      static forRoot(storageConfig?: StorageConfig): ModuleWithProviders<IonicStorageModule>;

[14:39:20]  typescript: {PROJECT_ROOT}/node_modules/@ionic/storage/storage.d.ts, line: 113
            An accessor cannot be declared in an ambient context.

     L112:  get driver(): string | null;
     L114:   * Reflect the readiness of the store.

[14:39:20]  ionic-app-script task: "build"
[14:39:20]  Error: Failed to transpile program
Error: Failed to transpile program
    at new BuildError ({PROJECT_ROOT}\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28)
    at {PROJECT_ROOT}\node_modules\@ionic\app-scripts\dist\transpile.js:159:20
    at new Promise (<anonymous>)
    at transpileWorker ({PROJECT_ROOT}\node_modules\@ionic\app-scripts\dist\transpile.js:107:12)
    at Object.transpile ({PROJECT_ROOT}\node_modules\@ionic\app-scripts\dist\transpile.js:64:12)
    at {PROJECT_ROOT}\node_modules\@ionic\app-scripts\dist\build.js:109:82
[ERROR] An error occurred while running subprocess ionic-app-scripts.

        ionic-app-scripts.cmd build --target cordova --platform android exited with exit code 1.

I have tried updating packages, removing & installing node modules, updating init scripts and nothing helped.

Here is my package json

{
  "name": "{}",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/core": "^4.20.0",
    "@ionic-native/firebase": "^4.20.0",
    "@ionic-native/keyboard": "^4.20.0",
    "@ionic-native/push": "^4.20.0",
    "@ionic-native/splash-screen": "4.9.1",
    "@ionic-native/status-bar": "4.9.1",
    "@ionic/storage": "^2.3.1",
    "cordova-android": "^8.1.0",
    "cordova-ios": "^4.5.5",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-sms-receiver": "0.1.6",
    "cordova-plugin-splashscreen": "^5.0.4",
    "cordova-plugin-whitelist": "^1.3.4",
    "ionic": "^5.4.16",
    "ionic-angular": "3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "phonegap-plugin-push": "^2.3.0",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.2.4",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "phonegap-plugin-push": {
        "FCM_VERSION": "11.6.2"
      },
      "cordova-plugin-sms-receive": {},
      "cordova-plugin-sms-receiver": {}
    },
    "platforms": [
      "android"
    ]
  }
}

Can anyone help me with it?

like image 768
Roy Rashti Avatar asked Dec 04 '22 17:12

Roy Rashti


1 Answers

Your Angular and Ionic dependencies are somehow old and need to be updated.

As the @ionic/storage is using the latest dependencies, so there was a conflict and you app wasn't able to compile it.

You can try to downgrade the version to v2.2.0 or lower and try again.

npm i @ionic/[email protected] --save

like image 60
yazantahhan Avatar answered Jan 11 '23 08:01

yazantahhan