kristerkari / react-native-svg-transformer

Import SVG files in your React Native project the same way that you would in a Web application.
MIT License
1.61k stars 116 forks source link

Error: Cannot find module 'react-native-svg-transformer/expo' #389

Open YANGHYUK opened 1 week ago

YANGHYUK commented 1 week ago

I'm trying to build expo with this command. eas build --profile production --platform android --local it failed with proguard. (but without proguard , it succeeds. eas build --profile preview --platform android --local )

eas.json

"preview": {
      "env": {
        "EXPO_PUBLIC_API_URL": "***********",
        "NODE_ENV": "development"
      },
      "android": {
        "buildType": "apk"
      },
      "distribution": "internal",
      "channel": "preview"
    },
 "production": {
      "env": {
        "EXPO_PUBLIC_API_URL": "***********",
        "NODE_ENV": "production"
      },
      "android": {
        "buildType": "app-bundle",
        "distribution": "internal",
        "env": {
          "PROGUARD_ENABLED": "true"
        }
      },
      "channel": "production"
    }

app.json

"plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "enableProguardInReleaseBuilds": true,
            "extraProguardRules": "-keep public class com.horcrux.svg.** {*;}"
          }
        }
      ]
    ],

metro.config.js

const { getDefaultConfig } = require('expo/metro-config');

module.exports = (() => {
  const config = getDefaultConfig(__dirname);

  const { transformer, resolver } = config;

  config.transformer = {
    ...transformer,
    babelTransformerPath: require.resolve('react-native-svg-transformer/expo'),
  };
  config.resolver = {
    ...resolver,
    assetExts: resolver.assetExts.filter((ext) => ext !== 'svg'),
    sourceExts: [...resolver.sourceExts, 'svg'],
  };

  return config;
})();

whole error!

image

YANGHYUK commented 1 week ago

"NODE_ENV": "production"

I found something weird. when i remove "NODE_ENV": "production"

Build is successful.

 "production": {
      "env": {
        "EXPO_PUBLIC_API_URL": "******"
        // "NODE_ENV": "production" => remove
      },
      "android": {
        "buildType": "apk",
        "env": {
          "PROGUARD_ENABLED": "true"
        }
      },
      "distribution": "internal",
      "channel": "production"
    }
brunocentanaro commented 1 day ago

The same happened to me and removing the node env also fixed it