Skip to content

Env variable is displaying as Undefined. #11

@sadashivm

Description

@sadashivm

Hi @kunalpanchal ,
I'm using your npm package with react js application. it is not working properly.
I followed the below steps,

  1. Installed it locally like :

    image

  2. In package.json it looks like:

    image

  3. Created .env file in the root directory and added below key values
    CLIENT_ID=1234
    API_KEY=4455

  4. My current npm version is :

    image

  5. It is greater than v5.2, so I ran the below command.
    npx secure-env .env -s SecretkeyHelloWorld

  6. After that it is created env.enc file. and I deleted .env file to prevent stealing.

  7. I have added below lines in index.js,
    let secureEnv = require('secure-env');
    global.env = secureEnv({secret:'SecretkeyHelloWorld'});

    image

  8. When I hover on packages it shows some warning message:

    image

  9. I start the application using below command
    npm start

  10. The env variables is displaying as undefined:

image

I also tried REACT_APP as prefix in .env file, still it's not working.
REACT_APP_CLIENT_ID=1234
REACT_APP_API_KEY=4455

Please let me know if I've missed out anything.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions