简体   繁体   English

环境变量不会用 javascript 中的新行替换 '\n' 并抛出错误:0909006C:PEMroutines:get_name:no start line

[英]Environment variables doesn't replace '\n' with new line in javascript and throw error:0909006C:PEM routines:get_name:no start line

I connected to my gmail account with google api using service account.我使用服务帐户通过谷歌 api 连接到我的 gmail 帐户。 while doing this, I got credentionals in .json file with 'private_key', looks something like:在执行此操作时,我在带有“private_key”的.json文件中获得了凭证,如下所示:

-----BEGIN PRIVATE KEY----- MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCfE0lFOu6odsZd vqCrXHbyFvalkMReFi1bo76tjSpNuJkDlHRKlx0ro+VZ0bqifIbo3yRGST+/Bxyr

now, I have to deploy my app, so I added the private_key to .env ,现在,我必须部署我的应用程序,所以我将private_key添加到.env

unfortunatly I get this error: Error: error:0909006C:PEM routines:get_name:no start line .不幸的是,我收到此错误: Error: error:0909006C:PEM routines:get_name:no start line

when console.log the proccess.env.private_key , I get it like this:当 console.log proccess.env.private_key时,我得到它是这样的:

-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCupQiD7fphkibb\nSRJ9x7tJLLWPvL+abF7pUsM30dwSxLtws4O83SFfDnRT9SYebZGz+9EVkv4VtSux\nzOhmLIBc3zUIAQyaD9VZFnZKFf5B0fjD/fp4Oq+AWXtMy

in one long line... and all the \n is still there instead of being replaced by a new line.在一长串中......并且所有\n仍然存在,而不是被新行替换。

       let privateKey =  process.env.PRIVATE_KEY.replace(/\\n/gm, '\n')

this regex replace the \n to brake line.此正则表达式将\n替换为刹车线。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase/admin 使用函数错误:错误:0909006C:PEM 例程:get_name:没有起始行 - Firebase/admin using functions Error: error:0909006C:PEM routines:get_name:no start line 为什么我在解码 JSON Web 令牌错误时出现这个错误:错误:0909006C:PEM 例程:get_name:没有起始行 - Why I am this Error in decoding JSON Web Token Error: error:0909006C:PEM routines:get_name:no start line 在 Blitz.js api 处理程序中运行时,Google Cloud Storage 调用失败并显示“error:0909006C:PEM routines:get_name:no start line” - Google Cloud Storage call fails with "error:0909006C:PEM routines:get_name:no start line" when run in Blitz.js api handler 使用 NodeJS 将数据编码为 JWT 令牌获取错误 PEM 例程:PEM_read_bio:没有起始行 - Encoding the data to JWT token with NodeJS getting error PEM routines:PEM_read_bio:no start line 换行符javascript不会插入新行“\\n” - Line break javascript doesn't insert new line "\n" npm 错误! 对 https://registry.npmjs.org/node-modules 的请求失败,原因:错误:0906D06C:PEM 例程:PEM_read_bio:没有起始行 - npm ERR! request to https://registry.npmjs.org/node-modules failed, reason: error:0906D06C:PEM routines:PEM_read_bio:no start line 将 \n 替换为 vuejs 上的新行 - replace \n to new line on vuejs 抛出新错误不会抛出错误,node.js不会抱怨不存在的变量 - Throw new Error doesn't throw and node.js don't complain about nonexistent variables PyV8将错误抛出到JavaScript /获取当前行号 - PyV8 throw error into JavaScript/get current line number JavaScript抛出新错误无法按要求运行 - JavaScript throw new Error doesn't work as required
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM