matthew
matthew

Reputation: 2254

How do I include and require a built-in node package in a React-Native app?

Node comes with some built-in packages, such as crypto. These are installed when Node is installed. They are not downloaded into the node_packages folder by npm.

How do I make one of these built-in packages available in my app so I can require it as follows:

const crypto = require('crypto');

Related unanswered question

Upvotes: 1

Views: 941

Answers (2)

matthew
matthew

Reputation: 2254

The mvayngrib/react-native-crypto Node.js package does this.

Upvotes: 0

Stewart
Stewart

Reputation: 496

The short answer is you can't.

crypto isn't pollyfilled by react-native, see issue 5049 for more info.

An alternative is to use a 3rd party module that attempts to mimic the crypto module in react-native but the few I checked were only partially implemented.

Upvotes: 2

Related Questions