-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
In the latest version of React Native (v0.79.1), using await directly is not allowed in certain places, which results in the following error
PATH: node_modules/bson/lib/bson.mjs
// Throw the error: property 'await' does not exist
The error occurs when attempting to use await directly for dynamic imports in the node_modules/bson/lib/bson.mjs file:
const nodejsRandomBytes = await (async () => {
try {
return (await import('crypto')).randomBytes;
}
catch {
return nodejsMathRandomBytes;
}
})();
Steps to Reproduce:
- Use React Native version 0.79.1
- Attempt to run the app with a dependency on the bson package and import them
- Observe the error message in the logs: "property 'await' does not exist".
Steps to Resolved
Replace that section with:
const nodejsRandomBytes = (async () => {
try {
constcrypto=awaitimport('crypto');
returncrypto.randomBytes;
}
catch {
returnnodejsMathRandomBytes;
}
})();