Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It failed because the native React runtime does not include the Node standard library

The package at node_modules\crypto-js\core.js attempted to import the Node standard library module crypto. It failed because the native React runtime does not include the Node standard library. Read more at https://docs.expo.io/workflow/using-libraries/#using-third-party-libraries

Getting this error when running npm start

like image 570
Raj Madheshia Avatar asked Apr 10 '26 22:04

Raj Madheshia


1 Answers

for expo instead of crypto you can use expo-crypto you can install it as below expo install expo-crypto

in your codes

import React, { useEffect } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import * as Crypto from 'expo-crypto';
  
export default function App() {
  useEffect(() => {
    (async () => {
      const digest = await Crypto.digestStringAsync(
        Crypto.CryptoDigestAlgorithm.SHA256,
        'Github stars are neat'
      );
      console.log('Digest: ', digest);
      /* Some crypto operation... */
    })();
  }, []);
...

as from expo documentation
like image 164
ndotie Avatar answered Apr 13 '26 03:04

ndotie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!