所以我正在使用Angular 6构建一个Web应用程序,使用AngularFire2,当我加载我的应用程序时,我收到此错误:
auth.js:255 Uncaught ReferenceError: global is not defined
at Object../node_modules/firebase/auth.js (auth.js:255)
at __webpack_require__ (bootstrap:81)
at Object../node_modules/firebase/firebase-browser.js (firebase-browser.js:11)
at __webpack_require__ (bootstrap:81)
at Object../src/app/core/auth.service.ts (auth.guard.ts:18)
at __webpack_require__ (bootstrap:81)
at Object../src/app/app.component.ts (main.js:156)
at __webpack_require__ (bootstrap:81)
at Object../src/app/app.module.ts (app.component.ts:9)
at __webpack_require__ (bootstrap:81)
./node_modules/firebase/auth.js @ auth.js:255
__webpack_require__ @ bootstrap:81
./node_modules/firebase/firebase-browser.js @ firebase-browser.js:11
__webpack_require__ @ bootstrap:81
./src/app/core/auth.service.ts @ auth.guard.ts:18
__webpack_require__ @ bootstrap:81
./src/app/app.component.ts @ main.js:156
__webpack_require__ @ bootstrap:81
./src/app/app.module.ts @ app.component.ts:9
__webpack_require__ @ bootstrap:81
./src/main.ts @ environment.ts:15
__webpack_require__ @ bootstrap:81
0 @ main.ts:14
__webpack_require__ @ bootstrap:81
checkDeferredModules @ bootstrap:43
webpackJsonpCallback @ bootstrap:30
(anonymous) @ main.js:1
我不确定它是否与我拥有的角度版本有什么关系,但是我有一个离子应用程序使用Angular 4使用这两个相同的库并且运行正常。
以下是相关的套餐:
"@angular/animations": "^6.0.1",
"@angular/common": "^6.0.1",
"@angular/compiler": "^6.0.1",
"@angular/core": "^6.0.1",
"@angular/forms": "^6.0.1",
"@angular/http": "^6.0.1",
"@angular/platform-browser": "^6.0.1",
"@angular/platform-browser-dynamic": "^6.0.1",
"@angular/platform-server": "^6.0.1",
"@angular/pwa": "^0.6.1",
"@angular/router": "^6.0.1",
"@angular/service-worker": "^6.0.1",
"@nguniversal/module-map-ngfactory-loader": "^6.0.0",
"angularfire2": "^4.0.0-rc.1",
"core-js": "^2.5.4",
"firebase": "^3.9.0"
我在这里错过了一些我正在使用的AngularFire和Firebase版本吗?
答案 0 :(得分:5)
作为一种临时手段,请转到pollyfill.ts文件(您可能会在应用程序的src文件夹中找到它)并将<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js" integrity="sha384-o+RDsa0aLu++PJvFqy8fFScvbHFLtbvScb8AjopnFD+iEQ7wo/CG0xlczd+2O/em" crossorigin="anonymous"></script>
<button type="button" data-toggle="modal" data-target="#exampleModal" class="btn btn-success">Click</button>
<div class="modal" id="exampleModal">
<div class="modal-dialog">
<div class="modal-content" style="height:100px;">
<div class="close-button">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
</div>
</div>
</div>
粘贴在文件末尾。