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

can't make it work with react-native-web #301

Closed
Benoit-ROBIN opened this issue Mar 24, 2022 · 3 comments
Closed

can't make it work with react-native-web #301

Benoit-ROBIN opened this issue Mar 24, 2022 · 3 comments
Labels
wontfix This will not be worked on

Comments

@Benoit-ROBIN
Copy link

I'm developing an app with react-native-web and I can't get react-native-dotenv to work in web mode.
My react-native-web setup works with react-scripts.
I do not use expo.
I didn't override the webpack config.

Is the lib compatible with react-native-web?
Is it necessary to modify the configuration of webpack?

Here are the errors I got:

ERROR in ./node_modules/dotenv/lib/main.js 24:11-24
Module not found: Error: Can't resolve 'fs' in '/Users/***/node_modules/dotenv/lib'
ERROR in ./node_modules/dotenv/lib/main.js 26:13-28

Module not found: Error: Can't resolve 'path' in '/Users/***/node_modules/dotenv/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
	- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "path": false }
ERROR in ./node_modules/dotenv/lib/main.js 28:11-24

Module not found: Error: Can't resolve 'os' in '/Users/***/node_modules/dotenv/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
	- install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "os": false }
ERROR in ./node_modules/react-native-dotenv/index.js 3:4-17

Module not found: Error: Can't resolve 'fs' in '/Users/***/node_modules/react-native-dotenv'
@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/301

@goatandsheep
Copy link
Owner

Are you importing this as a prod dependency? For projects, use devDependency. Only if you're building a babel lib (for whatever purpose) do you need this as a prod dependency. i should add this to the readme

@stale
Copy link

stale bot commented May 25, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label May 25, 2022
@stale stale bot closed this as completed Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants