vercel / storage

Vercel Postgres, KV, Blob, and Edge Config
https://vercel.com/storage
Apache License 2.0
480 stars 52 forks source link

Unable to resolve "@vercel/blob/client" #505

Open tryzeno opened 7 months ago

tryzeno commented 7 months ago

Using React Native with Expo and ran yarn add @vercel/blob. When I try to do:

import { upload } from "@vercel/blob/client";
 const newBlob = await upload(name, buffer....

I get:

Unable to resolve "@vercel/blob/client" from "screens/HomeScreen.tsx"

Version:

"@vercel/blob": "^0.15.1",
correttojs commented 7 months ago

hey @tryzeno, I just tested "@vercel/blob": "^0.15.1" and it seems to work well. Could you please share a full repro? The issue could be in the tscofing.json or in other configuration settings

tryzeno commented 7 months ago

Steps:

  1. Create new expo ts project: yarn create expo-app -t expo-template-blank-typescript
  2. Install "@vercel/blob": "^0.15.1"
  3. Change App.tsx to this
import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View } from "react-native";
import { upload } from "@vercel/blob/client";

export default function App() {
  return (
    <View style={styles.container}>
      <Text
        onPress={() => {
          upload(...);
        }}
      >
        Open up App.tsx to start working on your app!
      </Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

Just writing upload in there causes the error, you don't need to setup a whole api route or anything. Let me know if you are unable to replicate.

correttojs commented 7 months ago

I successfully executed expo start --web, I even uploaded some content

luismeyer commented 5 months ago

closing this since no update since 2 months. If the issue still exists feel free to reopen

olivierlesnicki commented 5 months ago

@correttojs it doesn't work with ios though

luismeyer commented 4 months ago

I found if you add:

"resolver": {
    "unstable_enablePackageExports": true
}

to your metro config, the bundler can correctly resolve the @vercel/blob/client import. This is needed because @vercel/blob relies on the exports field in the pjson.

This leads to a different error for me though where import * as crypto from "crypto" can't be resolved. Here it seems like the module resolution is wrong again. It's trying to import from node_modules/@vercel/dist/crypto-browser.js where the real path would be node_modules/@vercel/blob/dist/crypto-browser.js.

If you also run into this issue it might be worth opening an issue in expo or metro

sajeeIfonix commented 3 months ago

Using React Native with Expo and ran yarn add @vercel/blob. When I try to do:

import { upload } from "@vercel/blob/client";
 const newBlob = await upload(name, buffer....

I get:

Unable to resolve "@vercel/blob/client" from "screens/HomeScreen.tsx"

Version:

"@vercel/blob": "^0.15.1",

I too am getting this error in my react-native project (Expo CNG)

vvo commented 2 months ago

@sajeeIfonix Can you bring this issue over to the expo repository? Our package.json is correct as per https://arethetypeswrong.github.io/?p=%40vercel%2Fblob%400.22.3 so I suspect something is wrong with expo/expo setup here. It would be awesome to find out what 🙏

kevtechi commented 2 months ago

@sajeeIfonix Can you bring this issue over to the expo repository? Our package.json is correct as per https://arethetypeswrong.github.io/?p=%40vercel%2Fblob%400.22.3 so I suspect something is wrong with expo/expo setup here. It would be awesome to find out what 🙏

Thanks for looking into this. I guess we'll use AWS S3 until this issue is resolved.