Giter Club home page Giter Club logo

Comments (6)

evanshortiss avatar evanshortiss commented on May 24, 2024 2

This is available in the beta release of version 8. You can install and test it using npm install env-var@beta. Feel free to reopen this issue if necessary.

EDIT: See my latest comment in this thread for a fix with v7.x

from env-var.

evanshortiss avatar evanshortiss commented on May 24, 2024 1

@kenberkeley I have released v7.4.0 with this fix. You can now do the following for Vite environments:

const env = from(import.meta.env);

Or in React with create-react-app, you need to explicitly reference each variable like:

const env = from({
  SOME_VARIABLE: process.env.REACT_APP_SOME_VARIABLE
});

from env-var.

evanshortiss avatar evanshortiss commented on May 24, 2024

Thanks for raising this issue @smblee. I think it's a good point, and the module probably shouldn't assume that it's operating in a Node.js environment.

One problem is that I think this will break backwards compatibility, unless the code is changed to use some sort of conditional check.

If you change the line causing the issue to this, does it fix the issue?

module.exports = from(typeof process === 'undefined' ? {} : process.env) 

from env-var.

evanshortiss avatar evanshortiss commented on May 24, 2024

@smblee any luck with that fix? If so I can merge it into this module and push a patch release.

from env-var.

CassandraNewell avatar CassandraNewell commented on May 24, 2024

hi @evanshortiss , thanks for your work on this! Wanted to let you know that the beta worked just fine in my Vite React app -- head's up to anyone reading this, I had to place import.meta.env in an object like so:

const env = from({ variables: import.meta.env });

from env-var.

kenberkeley avatar kenberkeley commented on May 24, 2024

@evanshortiss May I ask when you will release the beta version?

from env-var.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.