简体   繁体   中英

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

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')

在此处输入图像描述

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM