Ionic 找不到 'localforage' 的类型定义文件
Ionic Cannot find type definition file for 'localforage'
Same question as forum.ionicframework.com
首先,我不在我的项目中使用打字。至少不是我所知道的。我也不使用 localforage,但它是 @ionic/storage 的依赖项。我确实安装了 typings 和 localforage,希望能解决这个问题,但它并没有解决它,而且可能还有残留物。
这是我不断收到的错误
>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!
这是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
也许有趣的是,每当我尝试 ionic cordova build android
我都会遇到这个问题
>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)
显然我已经安装了应用程序脚本。
另一件需要注意的重要事情是,当我 运行 ionic cordova prepare --no-build
脚本停止在 Preparing Firebase on Android
时,不确定这是否是故意的,或者 firebase 是否以某种方式停止了准备脚本.
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"
]
}
}
我使用 ionic start
、运行 npm install
和 ionic serve
创建了一个全新的空白项目。有同样的问题。
我没有在我的项目中使用 localforage,我真的不知道该怎么做。 Google 也没有回答。
完全重新安装 Node 后,此问题消失了。我不知道是什么损坏了,如果重新安装是唯一的解决方案,但它为我解决了。
Same question as forum.ionicframework.com
首先,我不在我的项目中使用打字。至少不是我所知道的。我也不使用 localforage,但它是 @ionic/storage 的依赖项。我确实安装了 typings 和 localforage,希望能解决这个问题,但它并没有解决它,而且可能还有残留物。
这是我不断收到的错误
>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!
这是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
也许有趣的是,每当我尝试 ionic cordova build android
我都会遇到这个问题
>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)
显然我已经安装了应用程序脚本。
另一件需要注意的重要事情是,当我 运行 ionic cordova prepare --no-build
脚本停止在 Preparing Firebase on Android
时,不确定这是否是故意的,或者 firebase 是否以某种方式停止了准备脚本.
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"
]
}
}
我使用 ionic start
、运行 npm install
和 ionic serve
创建了一个全新的空白项目。有同样的问题。
我没有在我的项目中使用 localforage,我真的不知道该怎么做。 Google 也没有回答。
完全重新安装 Node 后,此问题消失了。我不知道是什么损坏了,如果重新安装是唯一的解决方案,但它为我解决了。