Same question as forum.ionicframework.com
首先,我不在项目中使用打字。至少我不知道。我也不使用localforage,但这是@ ionic / storage的依赖项。我确实安装了打字程序和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是否以某种方式停止了prepare脚本。
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也没有给出答案。
答案 0 :(得分:0)
完全重新安装Node后,此问题消失了。我不知道什么东西损坏了,如果重新安装是唯一的解决方案,但是它为我解决了。