## TL;DR

Upgrade to replicate@0.29.3 or later instead of pinning 0.26.0. Fixed in 0.29.3 via PR #250.

## Steps

1. replicate-javascript 0.27.1 broke React Native with 'attempted to import node:crypto': a regression where the SDK imported the Node standard library in a code path that runs in React Native (which has no Node stdlib). Fixed in 0.29.3 via PR #250. Upgrade to replicate@0.29.3 or later instead of pinning 0.26.0.

2. https://github.com/replicate/replicate-javascript/issues/210: Issue replicate/replicate-javascript#210 (closed, 5 comments): When I install version 0.27.1 of replicate-javascript library in react-native project, I get error like below. Node Version: 18.18.0. The package at "node_modules/replicate/lib/util.js" attempted to import the Node standard library module "node:crypto". It failed because the native React runtime does not include the Node standard library. When I install version 0.26.0, it does not give any error. The problem seems to be related to the improvements made in the newly released version 0.27.1.

## When to use

You are seeing this: The package at "node_modules/replicate/lib/util.js" attempted to import the Node standard library module "node:crypto". Use this skill when you run into "React Native: package attempted to import node:crypto (0.27.1 regression)".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

Versions mentioned in the source: replicate-javascript 0.27.1, 0.29.3, pinning 0.26.0, 18.18.0. If you are on something much newer or older, the details may have shifted.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

## Sources

- https://github.com/replicate/replicate-javascript/issues/210:
