react-native-svg icon indicating copy to clipboard operation
react-native-svg copied to clipboard

Missing buffer dependency

Open acoates-ms opened this issue 7 months ago • 5 comments

Description

The buffer package is used here, but not declared as a dependency: https://github.com/software-mansion/react-native-svg/blame/15536f737388d66baf0d779dcbc7c2afc7ba1caa/src/utils/fetchData.ts#L2

Steps to reproduce

Use rn-svg in a pnpm workspace (or other packagemanager that enforces dependencies)

Snack or a link to a repository

None

SVG version

15.11.2

React Native version

0.78.2

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

acoates-ms avatar Jun 06 '25 21:06 acoates-ms

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

github-actions[bot] avatar Jun 06 '25 21:06 github-actions[bot]

I am also facing this problem. I got this error:

The package at "node_modules\react-native-svg\src\utils\fetchData.ts" attempted to import the Node standard library module "buffer".
It failed because the native React runtime does not include the Node standard library.
Learn more: https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries
  1 | import { Platform } from 'react-native';
> 2 | import { Buffer } from 'buffer';
    |                         ^
  3 |
  4 | export async function fetchText(uri?: string): Promise<string | null> {
  5 |   if (!uri) {

Import stack:

 node_modules\react-native-svg\src\utils\fetchData.ts
 | import "buffer"

 node_modules\react-native-svg\src\ReactNativeSVG.ts
 | import "./utils/fetchData"

 node_modules\react-native-svg\src\index.ts
 | import "./ReactNativeSVG"

 src\features\users\components\onboarding\NextButton.tsx
 | import "react-native-svg"

......


 src\app (require.context)

Can someone kindly check this?

farooqdotdev avatar Sep 17 '25 22:09 farooqdotdev

I am also facing this problem. I got this error:

The package at "node_modules\react-native-svg\src\utils\fetchData.ts" attempted to import the Node standard library module "buffer".
It failed because the native React runtime does not include the Node standard library.
Learn more: https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries
  1 | import { Platform } from 'react-native';
> 2 | import { Buffer } from 'buffer';
    |                         ^
  3 |
  4 | export async function fetchText(uri?: string): Promise<string | null> {
  5 |   if (!uri) {

Import stack:

 node_modules\react-native-svg\src\utils\fetchData.ts
 | import "buffer"

 node_modules\react-native-svg\src\ReactNativeSVG.ts
 | import "./utils/fetchData"

 node_modules\react-native-svg\src\index.ts
 | import "./ReactNativeSVG"

 src\features\users\components\onboarding\NextButton.tsx
 | import "react-native-svg"

......


 src\app (require.context)

Can someone kindly check this?

This simply solves the problem:

npm i buffer

farooqdotdev avatar Sep 18 '25 04:09 farooqdotdev

i am also facing the same issue but i want to know its need buffer and why its not mentioned int he official docs

code-harmony0 avatar Sep 26 '25 18:09 code-harmony0

This issue is labelled as "Missing repro".

There is no need to provide a "repro", as OP stated, this library code imports buffer module without declaring it as a dependency.

This code could help removing the buffer usage completely: https://github.com/sindresorhus/uint8array-extras/blob/033df7fe8d2d0f196ee0ec9110662cb97005ce30/index.js#L163

MichaelBorde avatar Nov 03 '25 14:11 MichaelBorde