Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

Angular and Realm Getting Started

Just getting started with Realm and I’m using Angular. I’ve been following this quick start:

https://docs.mongodb.com/realm/web/quickstart/

However, when I run ng serve, I get the following error:

ERROR in node_modules/realm-web/dist/bundle.d.ts:4:42 - error TS2307: Cannot find module 'realm-network-transport'.

4 import { Method, NetworkTransport } from 'realm-network-transport';
                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/realm-web/dist/bundle.d.ts:1:23 - error TS2688: Cannot find type definition file for 'realm'.

1 /// <reference types="realm" />
                        ~~~~~

Any ideas? I started with a brand new Angular app built with the Angular CLI.

@Kyle_Barnes Sorry about that - we are working on fixing this now. This a typescript issue at our end As a workaround for now, By removing the first line in node_modules/realm-web/dist/bundle.d.ts and install realm-network-transport the following TS script works:

import * as RealmWeb from "realm-web";
const app: RealmWeb.App = new RealmWeb.App({ id: "<my-app-id>" });
const credentials = RealmWeb.Credentials.anonymous();
app.logIn(credentials).then(user => {
console.log(`${user.id} is logged in`);
}).catch(err => {
console.error("Failed to log in", err);
});

Thanks @Ian_Ward for getting back to me. This did resolve the one issue, but now when I try to instantiate the app:

const app: RealmWeb.App = new RealmWeb.App({ id: "<my-app-id>" });

I am getting the following error:

I am super excited about Realm, but I’m a developer that mainly focused on line of business applications that are used in a desktop environment. It would be great if there was a session that covered Realm and Angular / React integration.

@Kyle_Barnes the original issue should be fixed now, as we just released Realm Web v0.3.0.
Again, sorry for the mixup on our part and thanks for reporting this.

For your the issue I can see that the bson dependency has an open issue, with the same error message. We’ll release a fix for this shortly.

@Kyle_Barnes I’ve just verified that the second issue has now been fixed with Realm Web v0.4.0.

@kraenhansen All is working now. Thank you very much for the quick fix. I’m excited to see how far this can go!

1 Like