tschoffelen / react-native-email-link

📭 Open an email client from React Native (for 'magic link' type functionality).
MIT License
394 stars 70 forks source link

[Expo] Failed to resolve plugin for module "react-native-email-link" #96

Closed MicaelRodrigues closed 2 years ago

MicaelRodrigues commented 2 years ago

Expo is unable to resolve the react-native-email-link plugin.

Steps to reproduce: 1 - expo init 2 - Add "plugins": ["react-native-email-link"] to app config. 3 - expo config --type prebuild

Note: expo --version: 4.12.1

tschoffelen commented 2 years ago

Just to confirm - did you run yarn add react-native-email-link or npm install react-native-email-link?

MicaelRodrigues commented 2 years ago

Hello, i used yarn

MicaelRodrigues commented 2 years ago

@tschoffelen I just retried in clean expo projects (both vanilla and TS templates) and it worked, so the problem must be with the configuration of the project i'm working on. I'll be sure to check what's wrong.

So, i'm sorry and i'm closing this issue..

Best regards

tschoffelen commented 2 years ago

Thanks Michael! Feel free to let me know if there's anything we can do to make the package work better with a custom configuration.

MicaelRodrigues commented 2 years ago

Hi @tschoffelen, I found the "conditions" that replicate the error:

https://snack.expo.dev/@micaelrodrigues/rn-email-link-config

Best regards

pekq commented 2 years ago

Faced the same problem. Couldn't find the root cause of it. As a temporary workaround, I copied the plugin into our project's dir structure and imported from there:

const withCommonConfig = (config) => {
  return {
    ...config,
    plugins: ['./expo-plugins/with-email-link']
  }
}
tschoffelen commented 2 years ago

cc @matt-oakes

matt-oakes commented 2 years ago

@MicaelRodrigues 👋 Can you explain a bit more about the snack you posted? There's no error message from running that and everything looks to be set up correctly there.

The most likely cause of this is either some sort of cachine inside Expo, or not having the correct version of the library installed.

What seems to be missing from these reports is the full error message you're getting and a minimal example project that shows the error when run. If someone could put that together, it would help with finding the issue.

MicaelRodrigues commented 2 years ago

@MicaelRodrigues 👋 Can you explain a bit more about the snack you posted? There's no error message from running that and everything looks to be set up correctly there.

Download the snack, run yarn and run expo config --type prebuild. You should the same error message. (I'm using Mas OS Big Sur if that matters.)

The most likely cause of this is either some sort of cachine inside Expo, or not having the correct version of the library installed.

I have the last version, and I don't have the same problem with other plugins, such as the one from expo example.

What seems to be missing from these reports is the full error message you're getting and a minimal example project that shows the error when run. If someone could put that together, it would help with finding the issue.

The most verbose error i get is Failed to resolve plugin for module "react-native-email-link" relative to "<PROJECT_PATH>".

saerdyey commented 2 years ago

I am getting a similar issue with using babel.config.js file for plugins. The error says Cannot find module 'babel-plugin-react-native-email-link'

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: [
      "react-native-email-link",
    ],
  };
};
tschoffelen commented 2 years ago

@saerdyey I think you might be adding it into the wrong file - this should go into your Expo config file (app.config.js) not the Babel config file.

saerdyey commented 2 years ago

@saerdyey I think you might be adding it into the wrong file - this should go into your Expo config file (app.config.js) not the Babel config file.

Thank you for informing me @tschoffelen . I just added it there because the babel config file was already there when I initialized the project. I also used other plugins configured there like dotenv, they worked fine so I thought it is alright doing it there.

fermmm commented 2 years ago

Same issue here: Failed to resolve plugin for module "react-native-email-link" relative to "<PROJECT_PATH>".

tschoffelen commented 2 years ago

For people experiencing this problem and it blocking them from using the library, here is a temporary solution:

  1. Remove the plugin from your Expo config file.
  2. Follow the old instructions to enable on iOS.

If anybody with more Expo experience than me has a solution for this issue, please do let me know/submit a PR. Keen to get this resolved, but I don't have the knowledge/time to do so!

ryanhyslop commented 2 years ago

I was getting this error also. ESLint was also failing for us with this error: Error: Cannot find module '/Users/ryanhyslop/Developer/my-sports-wellbeing-app/node_modules/react-native-email-link/index'. Please verify that the package.json has a valid "main" entry

Looking into the package.json we have main: index set but there is no index.js in the project, just index.(ios|android).js

Now this could be effecting us due to some local configuration/environment issues and I'm not sure what the best course of action here is but adding an empty index.js file into the repo resolves both issues for us? Perhaps the index could conditionally require the platform index, even if it is a bit redundant? 🤷

RicardoBrito1938 commented 2 years ago

Hello guys, i tried all the solutions before and none worked in my expo project, same error, i am running on "expo": "~43.0.2", i will keep trying to workaround and post if i find any solution

flexbox commented 2 years ago

Hey @RicardoBrito1938

I successfully used a mix of 2 libraries to make it work on iOS and Android with Expo (no plugins required) react-native-email-link and expo-intent-launcher using pure JavaScript

The code is available here https://davidl.fr/blog/react-native-expo-email-app

RicardoBrito1938 commented 2 years ago

Hey @RicardoBrito1938

I successfully used a mix of 2 libraries to make it work on iOS and Android with Expo (no plugins required) react-native-email-link and expo-intent-launcher using pure JavaScript

The code is available here https://davidl.fr/blog/react-native-expo-email-app

  • for iOS it opens the Apple Mail app even if another email app is installed (I tested with sparks). I guess it's kind of okay for now until the plugin solution works everywhere sweat_smile

that saved me, thank you so much

jkimbo commented 2 years ago

Found a solution to this: #100