Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
YANGHYUK opened this issue Nov 2, 2024 · 4 comments
Open

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

YANGHYUK opened this issue Nov 2, 2024 · 4 comments

Comments

@YANGHYUK
Copy link

YANGHYUK commented Nov 2, 2024

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
Copy link
Author

YANGHYUK commented Nov 2, 2024

"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
Copy link

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

@sp0033212000
Copy link

Is there any update to fix this issue?

@kristerkari
Copy link
Owner

Is there any update to fix this issue?

There is probably nothing that I can fix in this library.

react-native-svg-transformer is a normally a development dependency, so it might get excluded when running with the production node env.

I guess that the best workaround is not set the NODE_ENV = 'production' env variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants