我在使用Ionic 2,Firebase 3,AngularFire 2最新版本时遇到了不同的问题。
的问题:
node_modules/angularfire2/angularfire2.d.ts(13,66): error TS2503: Cannot find namespace 'firebase'.
typings/modules/firebase/index.d.ts(498,1): error TS2300: Duplicate
identifier 'export='.
at ReturnStatement.eachChild (/Users/ME/project/node_modules
/rollup/dist/rollup.js:5168:5)
at ReturnStatement.bind (/Users/ME/project/node_modules/roll
up/dist/rollup.js:5151:7)
at BlockStatement.bind (/Users/ME/project/node_modules/rollu
p/dist/rollup.js:5617:9)
at FunctionDeclaration.bind (/Users/ME/project/node_modules/
rollup/dist/rollup.js:6405:13)
at ExportNamedDeclaration.bind (/Users/ME/project/node_modul
es/rollup/dist/rollup.js:6223:44)
修改:
好的,我把它添加到我的tsconfig.json
:
{ "compilerOptions": {
...
"typeRoots": [
"../node_modules/@types"
],
// ADD THIS
"types": [
"firebase"
]
}
}
我遇到了这个问题:
Error: Module /Users/me/project/node_modules/angularfire2/node_modules/firebase/firebase-browser.js does not export initializeApp (imported by /Users/me/project/node_modules/angularfire2/angularfire2.js)
at Module.trace (/Users/me/project/node_modules/rollup/dist/rollup.js:7677:29)
at ModuleScope.findDeclaration (/Users/me/project/node_modules/rollup/dist/rollup.js:7300:22)
at Scope.findDeclaration (/Users/me/project/node_modules/rollup/dist/rollup.js:5351:39)
at CallExpression.bind (/Users/me/project/node_modules/rollup/dist/rollup.js:5826:28)
at /Users/me/project/node_modules/rollup/dist/rollup.js:5151:50
at ReturnStatement.eachChild (/Users/me/project/node_modules/rollup/dist/rollup.js:5168:5)
at ReturnStatement.bind (/Users/me/project/node_modules/rollup/dist/rollup.js:5151:7)
at BlockStatement.bind (/Users/me/project/node_modules/rollup/dist/rollup.js:5617:9)
at FunctionDeclaration.bind (/Users/me/project/node_modules/rollup/dist/rollup.js:6405:13)
at ExportNamedDeclaration.bind (/Users/me/project/node_modules/rollup/dist/rollup.js:6223:44)
更新:
我发现了这一点 https://github.com/angular/angularfire2/issues/545#issuecomment-248712121
但它尚未完美运作。
错误:
firebase.js:10Uncaught TypeError: Cannot read property 'navigator' of undefined
请帮忙吗?
答案 0 :(得分:0)
一位程序员在他的blog上写了一个解决方案。它对我有用。
答案 1 :(得分:0)
我尽量让我的Ionic 2 + AngularFire 2 config tutorial保持最新状态。
短篇小说:
$ npm install -g ionic@latest cordova typescript
@ionic/app-scripts
$ npm install @ionic/app-scripts@latest --save-dev
$ npm install @types/request@0.0.30 --save-dev --save-exact
$ npm install firebase angularfire2 --save
app.module.ts
```
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
// Importing pages
import { HomePage } from '../pages/home/home';
// Import the AF2 Module
import { AngularFireModule, AuthProviders, AuthMethods } from 'angularfire2';
// AF2 Settings
export const firebaseConfig = {
apiKey: "",
authDomain: "",
databaseURL: "",
storageBucket: "",
messagingSenderId: ""
};
const myFirebaseAuthConfig = {
provider: AuthProviders.Password,
method: AuthMethods.Password
}
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
IonicModule.forRoot(MyApp),
AngularFireModule.initializeApp(firebaseConfig, myFirebaseAuthConfig)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
]
})
export class AppModule {}
```
答案 2 :(得分:0)
要解决firebase.js:10 Uncaught TypeError: Cannot read property 'navigator' of undefined
问题,您需要添加useStrict: false
。如果您使用以下内容,它应该放在正确的位置:
rollup.rollup({
})
.then(function (bundle) {
bundle.write({
format: "iife",
dest: "./dist/app.js",
useStrict: false
});
});