error while using expo-image-picker:TypeError: undefined is not an object (evaluating '_expoModulesCore.NativeModulesProxy.ExponentImagePicker')

Viewed 419

im using expo-image-picker i am facing this
Error: Requiring module "node_modules\expo-image-picker\build\ImagePicker.js", which threw an exception: TypeError: undefined is not an object (evaluating '_expoModulesCore.NativeModulesProxy.ExponentImagePicker')

enter image description here

this is my code.

import * as ImagePicker from 'expo-image-picker'

;(async () => {
      let pickerResult = await ImagePicker.launchImageLibraryAsync({
        mediaTypes: ImagePicker.MediaTypeOptions.Images,
        base64: true,
        aspect: [4, 3],
        quality: 0.5,
      })

      if (pickerResult.cancelled === true) {
        return
      }
      let locaUri = pickerResult.uri
      //console.log(pickerResult.base64)
      let image: string = pickerResult.base64!

    })()

im getting error when start the app

1 Answers

This may due to expo not discover the package yet even though is install Now open directory in your node_modules and note may be your terminal reload. once you get to the file,

"node_modules\expo-image-picker\build\ImagePicker.js" save it. if error disappear from console it will work

import * as ImagePicker from 'expo-image-picker';


const openGallary  =async () => {
    // No permissions request is necessary for launching the image library
    let result = await ImagePicker.launchImageLibraryAsync({
      mediaTypes: ImagePicker.MediaTypeOptions.All,
      allowsEditing: true,
      aspect: [4, 3],
      quality: 1,
    });

    console.log(result);

    if (!result.cancelled) {
      setImage(result.uri);
    }
  
}
this is what i did and it work for me

Related