- 
    Type:Question 
- 
    Resolution: Community Answered
- 
    Priority:Major - P3 
- 
    None
- 
    Affects Version/s: 5.0.0
- 
    Component/s: BSON
- 
        1
- 
        Not Needed
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
What problem are you facing?
When importing ObjectId from bson browser throws "Uncaught ReferenceError: await is not defined" at nodejsRandomBytes
What driver and relevant dependency versions are you using?
mongo 5.0
node v16.20.2
Steps to reproduce?
Create a web app project with parcel or vite
Install the mongo 5.0 as a dependency
Import ObjectId from bson and use it on the client side
The browser will throw an error from nodejsRandomBytes
Uncaught ReferenceError: await is not defined
    at 2hiev.c2053a55dbc6d0ad (node_byte_utils.ts:49:1)
    at newRequire (index.0641b553.js:71:24)
    at localRequire (index.0641b553.js:84:35)
    at bNKaB.bson (app.js:1:1)
    at newRequire (index.0641b553.js:71:24)
    at index.0641b553.js:122:5
    at index.0641b553.js:145:3
Repo to reproduce the issue mateo-morales-garcia-gamecoderstudios/bson-not-working-parcel: testing object id from bson not working in parcel (github.com)
Also managed to reproduce it with vite here https://stackblitz.com/edit/vitejs-vite-hwav3o?file=src%2Fcounter.ts
- is related to
- 
                    NODE-3376 Node.js BSON dist cannot serialize browser BSON dist ObjectId -         
- Closed
 
-         
- 
                    NODE-6301 bson node es6 module import issue inside react app -         
- Closed
 
-         
- 
                    NODE-6917 Property await does not exist in the latest version of React Native (v0.79.1), error thrown in node_modules/bson/lib/bson.mjs -         
- Closed
 
-         
- 
                    NODE-4211 "bson" package: Browser shouldn't require("crypto") -         
- Closed
 
-         
- 
                    NODE-5816 NextJS 14 await is not defined -         
- Closed
 
-         
- related to
- 
                    NODE-5081 bson libruary can't be used -         
- Closed
 
-         
- 
                    NODE-5152 Remove RequireRewriter rollup transformer -         
- Closed
 
-         
- 
                    NODE-6321 Remove import of crypto from js-bson -         
- Closed
 
-         
- 
                    NODE-5816 NextJS 14 await is not defined -         
- Closed
 
-