【发布时间】:2019-09-04 03:38:21
【问题描述】:
我正在尝试在我的 Angular 7 应用程序中添加与 MongoDB Stich 的连接,但应用程序失败并出现错误:
bson.browser.esm.js:453 Uncaught ReferenceError: global is not defined
我正在使用 Angular 7.2.12 并已安装 mongodb-stitch-browser-sdk v 4.3.2
我正在使用 MongoDB 网站上 DB Stitch 应用程序客户端设置下的代码。
import { Component, OnInit } from '@angular/core';
import { Stitch, RemoteMongoClient, AnonymousCredential} from 'mongodb-stitch-browser-sdk'
@Component({
selector: 'app-alfabetisk',
templateUrl: './alfabetisk.component.html',
styleUrls: ['./alfabetisk.component.css']
})
export class AlfabetiskComponent implements OnInit {
constructor() { }
ngOnInit() {
const client = Stitch.initializeDefaultAppClient('app-id');
}
}
应用程序在 ngOnInit() 中失败并出现错误:
bson.browser.esm.js:453 Uncaught ReferenceError: global is not defined 在 Module../node_modules/bson/dist/bson.browser.esm.js (bson.browser.esm.js:453) 在 webpack_require (bootstrap:78) 在 Module../node_modules/mongodb-stitch-core-sdk/dist/esm/index.js (index.js:1) 在 webpack_require (bootstrap:78) 在 Module../node_modules/mongodb-stitch-browser-core/dist/esm/index.js (index.js:1) 在 webpack_require (bootstrap:78) 在 Module../node_modules/mongodb-stitch-browser-sdk/dist/esm/index.js (index.js:1) 在 webpack_require (bootstrap:78) 在 Module../src/app/alfabetisk/alfabetisk.component.ts (main.js:95) 在 webpack_require (bootstrap:78)
【问题讨论】:
标签: angular mongodb mongodb-stitch