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

using with ESlint #120

Closed
ph98 opened this issue Feb 14, 2021 · 12 comments · Fixed by #142
Closed

using with ESlint #120

ph98 opened this issue Feb 14, 2021 · 12 comments · Fixed by #142

Comments

@ph98
Copy link

ph98 commented Feb 14, 2021

Hi
When i use this line
import { GOOGLE_WEBCLIENTID } from '@env';

I'll face this error from ESlint:
Unable to resolve path to module '@env'.eslintimport/no-unresolved
of course I can use disable for this line eslint. but isn't there a better way?
thanks.

@github-actions
Copy link

Hey, thank you for opening this issue! 🙂 To boost priority on this issue and support open source please tip the team at https://issuehunt.io/r/goatandsheep/react-native-dotenv/issues/120

@goatandsheep
Copy link
Owner

I'll take a proper look later this week but for now try to either add @env as a constant in your babel config or change @env to react-native-dotenv as your moduleName in your babel and then also in the import line.

@junqdu
Copy link

junqdu commented Feb 20, 2021

change @env to react-native-dotenv as your moduleName in your babel and then also in the import line.

This worked for me, @goatandsheep thanks!

@unit-002
Copy link

unit-002 commented Mar 2, 2021

same here when importing google web client ID I also get:

"WEB_CLIENT_ID" is not defined in .env

and if I did change module name like @goatandsheep said I get:

unable to resolve module fs from node_modules\\react-native-dotenv\index.js: fs could not be found within the project

but if I import other key it works fine. I am only having this issue with google web client ID.

@goatandsheep
Copy link
Owner

@unit-002 is your key in the .env file? Also do not install the library as a dependency only Dev dependency. You may also want to check your babel config in the troubleshooting guide in the wiki

@unit-002
Copy link

unit-002 commented Mar 2, 2021

@unit-002 is your key in the .env file? Also do not install the library as a dependency only Dev dependency. You may also want to check your babel config in the troubleshooting guide in the wiki

yes all are in the .env file, the key consist of short numbers and letters only while google client id is very long, I'm not sure if there is a limit number of character but the keys are importing without problem. I am putting them for now in .env for testing purposes.

I already have the babel config like this:

"plugins": [
    ["module:react-native-dotenv", {
      "moduleName": "@env",
      "path": ".env",
      "blacklist": null,
      "whitelist": null,
      "safe": false,
      "allowUndefined": false
    }]
  ]

@goatandsheep
Copy link
Owner

Huh! I'll add a test. I did a quick search and found this example ID in the docs: 1234567890-abc123def456.apps.googleusercontent.com

@unit-002
Copy link

unit-002 commented Mar 2, 2021

Huh! I'll add a test. I did a quick search and found this example ID in the docs: 1234567890-abc123def456.apps.googleusercontent.com

yes that is how google id looks like

@goatandsheep
Copy link
Owner

sorry that isn't it. tests passed despite the longer Google ID. There may be a caching issue? or an issue with how you've configured the .env file. take a look to see how cache clearing is done

@unit-002
Copy link

unit-002 commented Mar 3, 2021

I finally got it working I just deleted all folder in the user directory in my drive C manually all related to cache then rebuild the app and now its working, thanks a lot

@goatandsheep
Copy link
Owner

So the cache issue is showing up in every other issue. If this comes up again can you try this and let me know? https://www.npmjs.com/package/react-native-clean-project

@unit-002
Copy link

unit-002 commented Mar 4, 2021

So the cache issue is showing up in every other issue. If this comes up again can you try this and let me know? https://www.npmjs.com/package/react-native-clean-project

Sure, thanks

goatandsheep added a commit that referenced this issue Apr 6, 2021
goatandsheep added a commit that referenced this issue Apr 6, 2021
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

Successfully merging a pull request may close this issue.

4 participants