question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnhandledPromiseRejectionWarning: Error: error:0906D06C:PEM routines:PEM_read_bio:no start line

See original GitHub issue

I get the above error when I try initializing the drive with the jwt token. Below’s my implementation. the keys are valid and I downloaded the file from the google developer console.

...
const jwtClient = new google.auth.JWT({                                          
  email: secret.client_email,                                                    
  key: secret.private_key,                                                       
  scopes                                                                         
})                                                                               

const drive = google.drive({                                                     
  version: 'v3',                                                                 
  auth: jwtClient                                                                
})   

function workspace () {                                                          
  return new Promise(async (resolve, reject) => {                                
    const folder = await findFolder(workDir)                                     
    if (folder) return resolve(folder)                                           
     return createFolder(workDir)                                                 
       .then(({ data }) => resolve(data))                                         
        .catch(err => reject(err))                                                 
   })                                                                             
} 
...

const cwd = await workspace()
console.log(cwd)

workDir is a variable holding a reference to a string with the name of a working directory.

The weird thing is that this was working last week but then it stopped working for some reason.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

50reactions
bradwbradwcommented, Nov 15, 2018

i was using .env as well and this problem happened to me. To fix, I just had to wrap the value in the .env file in double quotes. Hope it helps someone.

NODE_ENV=production
API_KEY=abc
GOOGLE_API_KEY="-----BEGIN PRIVATE ... asdfasdf\n-----END PRIVATE KEY-----\n"

(edit) the other thing that just happened when going to prod was that something between the ENV var setting and the app replaced all \n with \\n, so i just had to do:

googleApiKey = _.replace(process.env.GOOGLE_API_KEY, new RegExp("\\\\n", "\g"), "\n")
5reactions
fontumicommented, Jun 4, 2019

i was using .env as well and this problem happened to me. To fix, I just had to wrap the value in the .env file in double quotes. Hope it helps someone.

NODE_ENV=production
API_KEY=abc
GOOGLE_API_KEY="-----BEGIN PRIVATE ... asdfasdf\n-----END PRIVATE KEY-----\n"

(edit) the other thing that just happened when going to prod was that something between the ENV var setting and the app replaced all \n with \\n, so i just had to do:

googleApiKey = _.replace(process.env.GOOGLE_API_KEY, new RegExp("\\\\n", "\g"), "\n")

THANK YOU!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js https pem error: routines:PEM_read_bio:no start line
I am messing with login form right now with node.js, I tried creating a pem key and csr using
Read more >
Error:0906D06C:PEM routines:PEM_read_bio:no start line
I have PFX Client certificate, I have import in Postman & It works absolutely fine. But while I'm trying with command line &...
Read more >
Node/Express server: PEM_read_bio:no start line - Help
Error : error:0906D06C:PEM routines:PEM_read_bio:no start line. I am using symlinks from live folder, so it is not the reason…
Read more >
`How to Fix the below PEM routines:PEM_read_bio:ba ...
ERROR SSLCommon - Can't read key file c:\program files\splunkuniversalforwarder\etc\certs\name.pem errno=151441510 error:0906D066:PEM.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found