【发布时间】:2020-12-17 13:20:31
【问题描述】:
我正在开发一个带有 Nativescript Angular 和代码共享的应用程序。几天前升级到 Angular 10 后一切正常。今天我想用插件nativescript-plugin-firebase 实现 Firebase,但是当我尝试运行我的应用程序时,我收到以下错误:
ERROR in ../node_modules/nativescript-plugin-firebase/firebase.js
Module not found: Error: Can't resolve 'tns-core-modules/application/application'
ERROR in ../node_modules/nativescript-plugin-firebase/messaging/messaging.js
Module not found: Error: Can't resolve 'tns-core-modules/application/application'
ERROR in ../node_modules/nativescript-plugin-firebase/admob/admob.js
Module not found: Error: Can't resolve 'tns-core-modules/platform/platform'
ERROR in ../node_modules/nativescript-plugin-firebase/messaging/messaging.js
Module not found: Error: Can't resolve 'tns-core-modules/platform/platform'
我假设它是由 Webpack 抛出的,因为它是在 webpack 编译期间记录的。 我的 package.json 看起来有点像这样:
{
"name": "application-name",
"nativescript": {
"id": "my.nativescript.app",
"tns-ios": {
"version": "6.5.2"
},
"tns-android": {
"version": "6.5.3"
}
},
"version": "0.0.0",
"scripts": {
// some scripts
},
"dependencies": {
"@angular/animations": "~10.0.0",
"@angular/common": "~10.0.0",
"@angular/compiler": "~10.0.0",
"@angular/core": "~10.0.0",
"@angular/forms": "~10.0.0",
"@angular/platform-browser": "~10.0.0",
"@angular/platform-browser-dynamic": "~10.0.0",
"@angular/router": "~10.0.0",
"@nativescript/angular": "~10.0.0",
"@nativescript/core": "rc",
"@nativescript/theme": "~2.2.1",
"core-js": "^2.6.9",
"nativescript-plugin-firebase": "^10.5.2",
"reflect-metadata": "~0.1.12",
"rxjs": "~6.5.5",
"tslib": "1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1000.2",
"@angular/cli": "~10.0.0",
"@angular/compiler-cli": "~10.0.0",
"@nativescript/tslint-rules": "~0.0.5",
"@nativescript/webpack": "~2.0.0",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.4.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"node-sass": "^4.7.1",
"protractor": "~5.4.3",
"tns-platform-declarations": "^6.5.15",
"ts-node": "~8.3.0",
"tslint": "^5.20.1",
"typescript": "~3.9.0"
}
}
为了理解错误,我尝试将上述文件中的导入更改为 tns-core-modules/application 等等。编译成功了,但是当我在模拟器上启动它时,应用程序就崩溃了。我也试过@nativescript/core/application/application。我得到了同样的错误。
我不知道如何解决此问题,因此我将不胜感激。
【问题讨论】:
标签: angular firebase webpack nativescript nativescript-angular