Cant deploy my gatsby site because of env variables

Hello by build I get this error

Error: error:0909006C:PEM routines:get_name:no start line
It is because I set .env variables … they working fine on computer but there is some issue.

I need advice to debug deploy Netlify App

thanks for help

hi there, welcome. where and how are you trying to set .env variables? We need a little more information on what you are trying to do before we can assist.

Thanks for answer… well they are set in Build & deploy key: GATSBY_CLIENT_EMAIL value: “projec…” it looks like it dont want to read quotation marks (") … on my computer works nice and if I get out quotation marks it runs same error like here

And using in gatsby-config on top I have
require(“dotenv”).config({
path: .env.${process.env.NODE_ENV},
})
and need to use it in
credentials: {
client_email: GATSBY_CLIENT_EMAIL,
private_key: GATSBY_PRIVATE_KEY
},

hi, are you setting up your environment variables here? I am still trying to understand what is happening :slight_smile:

here is some additional info:

Yes I did set them here. And cant find out why it is not working.

I have had a similar issue using a Firebase private key as an env variable.

If it is a similar issue, you could try processing the GATSBY_PRIVATE_KEY with JSON.parse()

credentials: {
  client_email: GATSBY_CLIENT_EMAIL,
  private_key: GATSBY_PRIVATE_KEY[0] === '-' ? GATSBY_PRIVATE_KEY : JSON.parse(GATSBY_PRIVATE_KEY)
}

See previous post:

Thank you. It did not work like you wrote but when I set it together it worked.

credentials: JSON.parse(${process.env.GATSBY_CREDENTIALS})

1 Like

Awesome :clap: glad you worked it out

Hi, @Jinksi, thank you for sharing your solution and, @l0st0, thank you for sharing the solution that worked for you also. Both answers are likely to be helpful if someone searches the community site for similar errors. :+1:

1 Like

@luke I am facing the same issue. But I am creating an environment variable to access my private keys with double-quotes. Settings > Build & deploy > Environment > Environment variables
Screenshot 2020-06-08 at 7.14.16 PM
Getting this error:

Hi, @rajan-magar, would you please take a look at these topic and let us know if they are helpful or not?

Hi @rajan-magar . I got the same issue.

I added a quote to SERVICE_ACCOUNT_PRIVATE_KEY. Like
SERVICE_ACCOUNT_PRIVATE_KEY="----key----"

Also in code, I added:
JSON.parse(SERVICE_ACCOUNT_PRIVATE_KEY)

It helped me.

2 Likes