error: Error: Unable to resolve module @env

See original GitHub issue

No matter what I do, it’s just not working.

babel.config.json:

{
    "presets": ["@babel/preset-react","module:metro-react-native-babel-preset"],
    "plugins": [
      ["module:react-native-dotenv", {
        "moduleName": "@env",
        "path": ".env",
        "safe": false,
        "allowUndefined": true
      }]
    ]
}

error:

error: Error: Unable to resolve module @env from /Users/maoryadin/spetz-git/project/src/constants/config.js: @env could not be found within the project or in these directories:
  node_modules
  ../../node_modules
  1 | import {AppColors, AppSizes, AppStyles} from '../theme';
  2 | import {Platform} from 'react-native';
> 3 | import {SERVER_URL, RATING_URL, ENV} from '@env';

I have a .env file that exists.

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
maoryadincommented, Dec 22, 2022

Hey, i have successfully succeeded, i think adding import react before has fixes the issue, not sure but its work 😃

0reactions
goatandsheepcommented, Dec 22, 2022

Can you please show me a test repo? I haven’t been able to break it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Unable to resolve module @env · Issue #308 ... - GitHub
Steps to reproduce the behavior: npm install react-native-dotenv; add .env to root dir; config babel.config.js as shown above; add ```import { ...
Read more >
react-native-dotenv Unable to resolve module @env
I'm setting up this lib for TypeScript like here. my env :
Read more >
Unable to resolve module `@env` from `src/utils.ts` - Issuehunt
error Unable to resolve module `@env` from `config.ts`: @env could not be found within the project. If you are sure the module exists,...
Read more >
jkim711 - Sendbird Community
error : Error: Unable to resolve module ./env from /Users/jaekim/code/sendbird_uikit/sendbird-uikit-react-native/sample/src/App.tsx:.
Read more >
I have an error it says: Error: Cannot find module '.env'
[nodemon] starting node ./index.js node:internal/modules/cjs/loader:936 throw err; ^ Error: Cannot find module '.env' Require stack: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found