react-native-dotenv: Expo throwing fs not found error.

Error Statement:

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.

Balblel.config

module.exports = function (api) {
  api.cache(false);
  return {
    presets: ["babel-preset-expo"],
    env: {
      production: {
        plugins: [
          ["react-native-paper/babel"],
          [
            "module:react-native-dotenv",
            {
              moduleName: "react-native-dotenv",
              verbose: true,
            },
          ],
        ],
      },
    },
  };
};

Environment:

Expo sdk ~47.0.12 React native 0.70.5 React 18.1.0

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

Thanks @goatandsheep That repo that you made worked. I can give you the bounty if you apply on Replit

@goatandsheep I accepted you, just submit something and I’ll approve it!

thank you! I uploaded a replit 😃 I realized you removed the yarn upgrades, so maybe it was the esModuleInterop. I will add that to the README

@patrickpistor I stalked your profile and noticed this package.json has react-native-dotenv in the dependencies array not devDependencies https://github.com/Photure/PhotureEthGlobal/blob/master/package.json

@goatandsheep that project is dated, this is the one I am using the correct package in the correct place https://github.com/patrickpistor/mixer.

The error seems to be around fs installing correctly at this point.