cordovaionic-frameworkionic3localforage

Ionic Cannot find type definition file for 'localforage'


Same question as forum.ionicframework.com

First of all, I do not use typings in my project. At least not that I know of. I also do not use localforage, but it's a dependency of @ionic/storage. I did install typings and localforage in hope to solve this issue but it didn't solve it and there may be residue left of those.

This is the error I keep getting

>ionic serve
> ionic-app-scripts serve --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser
[app-scripts] [10:38:53]  ionic-app-scripts 3.1.10
[app-scripts] [10:38:53]  watch started ...
[app-scripts] [10:38:53]  build dev started ...
[app-scripts] [10:38:55]  clean started ...
[app-scripts] [10:38:55]  clean finished in 10 ms
[app-scripts] [10:38:55]  copy started ...
[app-scripts] [10:38:58]  deeplinks started ...
[app-scripts] [10:38:58]  deeplinks finished in 283 ms
[app-scripts] [10:38:58]  transpile started ...
[app-scripts] [10:39:04]  typescript error
[app-scripts]             Cannot find type definition file for 'localforage'.

[INFO] Development server running!

       Local: http://localhost:8100
       External: http://145.74.203.18:8100, http://192.168.137.1:8100
       DevApp: Ionic_HerstelApp@8100 on DESKTOP-7D0ETN5

       Use Ctrl+C to quit this process

[INFO] Browser window opened to http://localhost:8100!

Here's the output of ionic info

Ionic:

   ionic (Ionic CLI)  : 4.1.2 (C:\Users\*****\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.10

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 1.2.1, (and 5 other plugins)

System:

   Android SDK Tools : 26.1.1 (C:\Users\*****\AppData\Local\Android\Sdk)
   NodeJS            : v6.11.4 (C:\Program Files\nodejs\node.exe)
   npm               : 6.4.1
   OS                : Windows 10

What's perhaps interesting is that whenever I try to ionic cordova build android I get this issue

>ionic cordova build android
> ionic-app-scripts build --target cordova --platform android
[10:55:25]  ionic-app-scripts 3.1.10
[10:55:26]  build dev started ...
[10:55:27]  clean started ...
[10:55:27]  clean finished in 13 ms
[10:55:27]  copy started ...
[10:55:30]  deeplinks started ...
[10:55:30]  deeplinks finished in 141 ms
[10:55:30]  transpile started ...
[10:55:36]  typescript error
[10:55:36]  ionic-app-script task: "build"
[10:55:36]  TypeError: Cannot read property 'replace' of null
TypeError: Cannot read property 'replace' of null
    at Object.escapeHtml (C:\symlinks\Ionic_HerstelApp\node_modules\@ionic\app-scripts\dist\util\helpers.js:253:9)
    at generateCodeBlock (C:\symlinks\Ionic_HerstelApp\node_modules\@ionic\app-scripts\dist\logger\logger-diagnostics.js:187:77)
    at generateDiagnosticHtml (C:\symlinks\Ionic_HerstelApp\node_modules\@ionic\app-scripts\dist\logger\logger-diagnostics.js:179:12)
    at Array.map (native)
    at Object.printDiagnostics (C:\symlinks\Ionic_HerstelApp\node_modules\@ionic\app-scripts\dist\logger\logger-diagnostics.js:15:39)
    at C:\symlinks\Ionic_HerstelApp\node_modules\@ionic\app-scripts\dist\transpile.js:158:34
    at transpileWorker (C:\symlinks\Ionic_HerstelApp\node_modules\@ionic\app-scripts\dist\transpile.js:107:12)
    at Object.transpile (C:\symlinks\Ionic_HerstelApp\node_modules\@ionic\app-scripts\dist\transpile.js:64:12)
    at C:\symlinks\Ionic_HerstelApp\node_modules\@ionic\app-scripts\dist\build.js:109:82
            Cannot find type definition file for 'localforage'.


[INFO] Looks like @ionic/app-scripts isn't installed in this project.

       This package is required for this command to work properly.

? Install @ionic/app-scripts? (Y/n)

Obviously I already have app-scripts installed.

Another thing that could be important to note is when I run ionic cordova prepare --no-build the script stops at Preparing Firebase on Android, not sure if that's intended or perhaps if firebase somehow stops the prepare script.

package.json

{
  "name": "ionic_herstel_app",
  "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.12.0",
    "@ionic-native/firebase": "^4.12.0",
    "@ionic-native/native-audio": "^4.12.0",
    "@ionic-native/splash-screen": "^4.12.0",
    "@ionic-native/status-bar": "^4.12.0",
    "@ionic/storage": "^2.1.3",
    "angularfire2": "5.0.0-rc.4",
    "cordova-android": "7.0.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-firebase": "^1.1.3",
    "cordova-plugin-ionic-keyboard": "^2.1.2",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-nativeaudio": "^3.0.9",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "firebase": "^4.5.0",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "ng-circle-progress": "1.0.0",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.10",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-firebase": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-nativeaudio": {}
    },
    "platforms": [
      "android"
    ]
  }
}

I made a fresh blank project using ionic start, ran npm install and then ionic serve. Got the same issue. I don't use localforage in my project and I really don't know how to go about this. Google gave no answers either.


Solution

  • This problem disappeared after clean reinstalling Node entirely. I do not know what was corrupt and if reinstalling is the only solution, but it solved it for me.