与 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 以某种方式停止准备脚本。
包.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,我真的不知道该怎么做。谷歌也没有给出答案。