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

The package at "node_modules\react-native-dotenv\index.js" attempted to import the Node standard library module "fs". It failed because the native React runtime does not include the Node standard library. #78

Closed
champ8644 opened this issue Sep 30, 2020 · 4 comments

Comments

@champ8644
Copy link

I was using expo with react-native-dotenv
with

    "expo": "^38.0.8",
    "react-native-dotenv": "^2.4.1",

and babel.config.js

module.exports = api => {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: [
      [
        'module:react-native-dotenv',
        {
          moduleName: '@env',
          path: '.env',
          blacklist: null,
          whitelist: null,
          safe: false,
          allowUndefined: false
        }
      ]
    ]
  };
};

I have use only this in my file

import {
  API_KEY,
  APP_ID,
  AUTH_DOMAIN,
  DATABASE_URL,
  MEASUREMENT_ID,
  MESSAGE_SENDER_ID,
  PROJECT_ID,
  STORA_BUCKET
} from '@env';

So after I read your suggestion of migrating to 2.x.x I tried your solution and still I can't seem to build an expo apps at all,
This is the error I got:

Failed building JavaScript bundle.
The package at "node_modules\react-native-dotenv\index.js" attempted to import the Node standard library module "fs". It failed because the native React runtime does not include the Node standard library. Read more at https://docs.expo.io/workflow/using-libraries/#using-third-party-libraries

I have tried everything and it doesn't seem to work. please help!
your sincere,
Charisu

@champ8644
Copy link
Author

edit: I fixed this issue by add this to my babel.config.js

{
    presets: ['babel-preset-expo', 'module:metro-react-native-babel-preset'],
    plugins: [
      [
        'module:react-native-dotenv',
        {
          moduleName: '@env',
          path: '.env',
          blacklist: null,
          whitelist: null,
          safe: false,
          allowUndefined: false
        }
      ]
    ]
  };

Closing this ._.
Thanks,
Charisu

@Raheemshah2809
Copy link

I have the same issue, tried Nov 2022, It doesnt work for me

@witherBattler
Copy link

Issue for me as well

@chrisdemetriad
Copy link

@champ8644's solution did not work for me.

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