根据我在这个 TS/Node 项目中遇到的错误(对于一个简单的 TypeScript only REST API)建议的修复(这里提到(https://github.com/heineiuo/rippledb/issues/148https://www.mongodb.com/compatibility/using-typescript-with-mongodb-tutorial
但是,Node 18.x 甚至降级到 Node v14.15.5 会在一个具有以下 ionic 配置的 ionic 3 项目中破坏构建 apk 和浏览器进程。
$ ionic info
Ionic:
Ionic CLI : 6.13.1 (C:\Users\AXM\AppData\Roaming\npm\node_modules\@ionic\cli)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.4
Cordova:
Cordova CLI : 11.0.0
Cordova Platforms : android 10.1.2, browser 5.0.3
Cordova Plugins : cordova-plugin-ionic-webview 4.1.3, (and 15 other plugins)
Utility:
cordova-res : 0.15.3
native-run : not installed
System:
Android SDK Tools : 26.1.1 (C:/Users/AXM/AppData/Local/Android/Sdk)
NodeJS : v10.16.0 (C:\Program Files\nodejs\node.exe)
npm : 6.9.0
OS : Windows 10 ...really 11 :)
我没有记录的最初投诉我相信 sass 失败的地方。谷歌搜索我遇到了这篇文章,虽然不是专门关于“离子 3”说降级。
"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",
"watch": "ionic-app-scripts watch && beep ",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build",
"run:after": "beep",
"serve:after": "beep",
"beep": "bash.exe beep.sh",
"beep0": "bash.exe -c \"echo -en '\\a' \" ",
"releasePWA": "ionic cordova build browser --prod --release"
},
"dependencies": {
"@angular/common": "5.0.3",
"@angular/compiler": "5.0.3",
"@angular/compiler-cli": "5.0.3",
"@angular/core": "5.0.3",
"@angular/forms": "5.0.3",
"@angular/platform-browser": "^5.0.3",
"@angular/platform-browser-dynamic": "5.0.3",
"@ionic-native/android-full-screen": "^4.20.0",
"@ionic-native/app-version": "^4.20.0",
"@ionic-native/clipboard": "^4.20.0",
"@ionic-native/core": "4.5.2",
"@ionic-native/document-viewer": "^4.7.0",
"@ionic-native/file": "^4.7.0",
"@ionic-native/file-transfer": "^4.7.0",
"@ionic-native/in-app-browser": "4.5.2",
"@ionic-native/ionic-webview": "^5.36.0",
"@ionic-native/social-sharing": "4.5.2",
"@ionic-native/splash-screen": "^4.7.0",
"@ionic-native/status-bar": "4.5.2",
"@ionic-native/toast": "4.6.0",
"@ionic/pro": "1.0.16",
"@ionic/storage": "2.1.3",
"@types/youtube": "0.0.46",
"archiver": "^5.3.1",
"child_process": "^1.0.2",
"clipboard-js": "0.3.3",
"com.verso.cordova.clipboard": "https://github.com/VersoSolutions/CordovaClipboard.git",
"cordova-browser": "5.0.3",
"cordova-clipboard": "~1.0.0",
"cordova-plugin-device": "1.1.4",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-file-transfer": "^1.7.1",
"cordova-plugin-fullscreen": "^1.2.0",
"cordova-plugin-inappbrowser": "~1.7.1-dev",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-plugin-x-socialsharing": "~5.1.6",
"cordova-plugin-x-toast": "~2.6.0",
"cordova-sqlite-storage": "~2.0.3",
"danielsogl-cordova-plugin-clipboard": "1.0.2",
"ionic-angular": "3.9.2",
"ionic-plugin-keyboard": "~2.2.1",
"ionicons": "3.0.0",
"node-apk": "^1.1.1",
"rxjs": "5.5.2",
"sw-toolbox": "3.6.0",
"url-exist": "^3.0.0",
"zone.js": "0.8.18"
},
"devDependencies": {
"@ionic/app-scripts": "^3.2.4",
"@types/node": "^9.6.61",
"cordova-android": "^10.1.2",
"cordova-plugin-apkupdater": "^4.0.0",
"cordova-plugin-app-version": "^0.1.14",
"cordova-plugin-ionic-webview": "^4.1.3",
"tslint": "^5.10.0",
"tslint-ionic-rules": "0.0.16",
"typescript": "^2.8.3",
"viewport-units-buggyfill": "0.6.2"
},
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-statusbar",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard",
"cordova-plugin-x-socialsharing"
],
"cordovaPlatforms": [
{
"platform": "android",
"version": "",
"locator": "android"
},
{
"platform": "browser",
"version": "",
"locator": "browser"
}
],
"description": "UPS.ion: project",
"config": {
"ionic_source_map": "source-map",
"ionic_copy": "./copy.config.js"
},
"cordova": {
"plugins": {
"cordova-sqlite-storage": {},
"cordova-plugin-x-toast": {},
"cordova-clipboard": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-file": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-device": {},
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"com.verso.cordova.clipboard": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-x-socialsharing": {},
"cordova-plugin-fullscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-apkupdater": {},
"cordova-plugin-app-version": {}
},
"platforms": [
"browser"
]
}
}
无论如何,我在解决这些问题方面很差,这是我的 package.json 我没有回到 Node v10.16.0,在构建时没有完全恢复一些奇怪的新问题
ionic cordova build browser --prod --release
我明白了
> ionic-app-scripts.cmd build --prod --target cordova --platform browser
[07:44:15] ionic-app-scripts 3.2.4
[07:44:15] build prod started ...
[07:44:15] clean started ...
[07:44:15] clean finished in 2 ms
[07:44:15] copy started ...
[07:44:15] deeplinks started ...
[07:44:15] deeplinks finished in 293 ms
[07:44:15] ngc started ...
[07:44:20] typescript error
Invalid provider for the NgModule 'AppModule in S:/_W/ARP/UPS.ion/SRC/UPS.ion.3/src/app/app.module.ts' -
only instances of Provider and Type are allowed, got: [[object Object], Clipboard in
S:/_W/ARP/UPS.ion/SRC/UPS.ion.3/node_modules/@ionic-native/clipboard/index.d.ts, Toast in
S:/_W/ARP/UPS.ion/SRC/UPS.ion.3/node_modules/@ionic-native/toast/index.d.ts, SocialSharing in
S:/_W/ARP/UPS.ion/SRC/UPS.ion.3/node_modules/@ionic-native/social-sharing/index.d.ts, AndroidFullScreen in
S:/_W/ARP/UPS.ion/SRC/UPS.ion.3/node_modules/@ionic-native/android-full-screen/index.d.ts, ?null?]
[07:44:20] ionic-app-script task: "build"
[07:44:20] Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
at S:\_W\ARP\UPS.ion\SRC\UPS.ion.3\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
at step (S:\_W\ARP\UPS.ion\SRC\UPS.ion.3\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
at Object.next (S:\_W\ARP\UPS.ion\SRC\UPS.ion.3\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
at fulfilled (S:\_W\ARP\UPS.ion\SRC\UPS.ion.3\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
[ERROR] An error occurred while running subprocess ionic-app-scripts.
ionic-app-scripts.cmd build --prod --target cordova --platform browser exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
我在谷歌上搜索了很多其他东西
- NgModule 'AppModule 的提供程序无效
- 错误:Angular AoT 构建失败
并进行了许多猜测工作(npm uninstall this... npm install that...)。我还清除了所有 lint 错误,但也无济于事。
有趣的是,删除 app.modules.ts 中的第 120..124 行下面显示的 5 个提供程序列表会使构建愉快,但浏览器构建不会运行,并且与 APK 构建相同。
[![enter image description here][1]][1]
也许还有一些其他的东西需要升级,以便有一个更新版本的 node 对这两个项目都有效(我不能失去我的 ionic3 项目)。
对不起,这很复杂...
回答1
使用不同版本的 Node 运行每个应用程序可能会有所帮助。 https://github.com/nvm-sh/nvm 工具非常适合,如果您还没有安装它,请继续安装它。
在一个 shell 中,安装较新的 Node 版本,例如nvm install lts/gallium
和 nvm use lts/gallium
。清除 node_modules 并重新安装依赖项 (rm -rf ./node_modules && npm i
) 并在那里运行您的服务器内容。
在另一个 shell 中,安装旧的 Node 版本,例如nvm install lts/erbium
和 nvm use lts/erbium
。同样,清除 node_modules 并重新安装依赖项 (rm -rf ./node_modules && npm i
) 并在那里运行您的 Ionic 3 项目。
如果这没有帮助,在 Github 上放置一个删除版本的应用程序,并附上复制错误的说明,这样可以最好地进行进一步的调试。