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

Is 'fs' a dependency of this package? #172

Closed
trip-somers opened this issue Jan 11, 2017 · 10 comments
Closed

Is 'fs' a dependency of this package? #172

trip-somers opened this issue Jan 11, 2017 · 10 comments

Comments

@trip-somers
Copy link

I do not have 'fs' installed, but when I use webpack, I get an error that 'fs' cannot be resolved. dotenv is the only new package added since my last webpack compile.

If it is a dependency, shouldn't it be listed in the package.json for the project? If it is not a dependency, can anyone give me a hint toward figuring out what I've done wrong?

@trip-somers
Copy link
Author

I've tracked this to a Webpack issue that requires a weird work-around. Basically, adding target: 'node' to the Webpack config fixed this.

I don't understand the cause or the fix, really, but this is clearly not an issue with this package.

@jcblw
Copy link
Collaborator

jcblw commented Jan 11, 2017

@trip-somers this issue might have some insight to the issue your running into, and maybe some ways to fix it #153

@maxbeatty
Copy link
Contributor

webpack includes DefinePlugin which accomplishes what dotenv would. Facebook's create-react-app uses it to populate a familiar process.env. In most cases, any environment variable you are sharing to a browser is safe to share to git

@trip-somers
Copy link
Author

I'm confused about how I didn't see #153 before I posted this issue. That would have saved me some time...

FWIW, I worked around this by moving the .env specific part of the code into an HTML template where I set a global JS variable for the value I need. Thanks for the comments.

@kachkaev
Copy link

I faced Error: Can't resolve 'fs' when trying npm run build:dll in react-boilerplate. It turned out that I accidentally listed dotenv in dependencies rather than devDependencies and after ctrl+x & ctrl+v the issue was gone.

@josephdburdick
Copy link

josephdburdick commented Feb 28, 2017

It can't be on accident when the README tells you to install with --save-dev though, right? I think some clarification is necessary here.

@canercandan
Copy link

common workaround, use https://github.com/mrsteele/dotenv-webpack

@bobbwhy
Copy link

bobbwhy commented May 25, 2018

thank you canercandan.. works a charm

abendy added a commit to abendy/chrome-extension-builder that referenced this issue Mar 21, 2019
@opcommander1
Copy link

canercandan: THAT WAS EXCELLENT INFO!!!

@ekkis
Copy link

ekkis commented Apr 9, 2020

common workaround, use https://github.com/mrsteele/dotenv-webpack

that doesn't seem to work in a React Native environment, but I did find: react-native-dotenv

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

9 participants