Missing buffer dependency
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
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?
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?
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
i am also facing the same issue but i want to know its need buffer and why its not mentioned int he official docs
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