Reference Error match is not defined ,Image Picker functions

I am using the following code in my expo app, which I used and worked fine till I wanted to make template and generate it using slush ,this error may be related to slush (sorry) but I am using expo in my template, and the error shown is related to expo code below:

ReferenceError: match is not defined

the code where match is actually included is as follows:

render() {
      return (
       <View style= {{flex:1}}>
              source={{uri:'<%= webURI%>'}}
              style={{ marginTop: 20  }} 
              ref={( webView ) => this.webView = webView}
                  if( =="gallery!"){
                  if( =="camera!"){

    _galleryImage = async () => {
      let pickerResult = await ImagePicker.launchImageLibraryAsync({
        exif: true,
        allowsEditing: false,
        quality: 0.7,
        base64: true,
      if (pickerResult.cancelled) {
    _cameraImage = async() =>{
          let result = await ImagePicker.launchCameraAsync({
                  allowsEditing: true,
                 aspect: [4, 3],
              if (result.cancelled) {
            let localUri = result.uri;
            let filename = localUri.split('/').pop();
            let match = /\.(\w+)$/.exec(filename);
            let type = match ? `image/${match[1]}` : `image`;
            let formData = new FormData();
            formData.append('photo', { uri: localUri, name: filename, type });


            return await fetch(YOUR_SERVER_URL, {
              method: 'POST',
              body: formData,
              header: {
                'content-type': 'multipart/form-data',

I just wanna add that this code is working FINE in the expo XDE but when I run the slush slush-generator with the slush command it gives ‘reference error match is not defined’

Thanks in advance,

Hi, Naveen.

I replied to your other post, but I wanted to say we really appreciate the effort you made to make an expo generator for slush. None of us are familiar with slush, so I’m sorry we can’t debug this problem, but it seems like a fun project.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.