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

Env variable is displaying as Undefined. #11

Open
sadashivm opened this issue Feb 6, 2020 · 4 comments
Open

Env variable is displaying as Undefined. #11

sadashivm opened this issue Feb 6, 2020 · 4 comments

Comments

@sadashivm
Copy link

sadashivm commented Feb 6, 2020

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.

@github-actions
Copy link

github-actions bot commented Feb 6, 2020

Thanks for raising the issue. Maintainer(s) will look into this shortly.

@AlexisLapeze
Copy link

hi, i have the same issue

@MarkKewley
Copy link

MarkKewley commented Jul 29, 2020

Not sure if it helps but I was using VueJS and realized you can use fs when bootstrapping the system. For my case placing this logic in the vue.config.js (Or a webpack.config.js for example) solved that error.

E.g.

vue.config.js

const secureEnv = require('secure-env');
const decrypted = secureEnv({ secret: 'mySecretPassword' });

process.env = {
  ...process.env,
  ...decrypted
};

module.exports = {
  transpileDependencies: ['vuetify']
};

Though not entirely sure this is what we need as it still shows up in the compiled js defeating the purpose of the encryption...More debugging I'm sure.

@Deepak9811
Copy link

Deepak9811 commented Mar 18, 2024

@sadashivm have you got the solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants