转义.env文件中的#字符 [英] Escaping the # character in .env file
问题描述
我想在我的Express服务器的环境文件中存储的秘密API密钥忽略了其中的一半,因为它的中间包含一个#符号.我无法重新生成密钥.并不想让它变得残缺
The secrete API key I want to store in my environment file for my express server is ignoring half of it as it contains a # symbol in the middle. I can't regenerate the key. And do not want it to be left unsequre
推荐答案
我不认为这是由于#
符号引起的.仅当在一行中遇到第一个图表作者时,才被视为发信号注释.您可以自己尝试.创建具有以下内容的 .env
文件:
i do not think it's because of the #
symbol. It is only treated as signaling a comment when encountered as first chartacter in a line...
you can try this yourself. create a .env
file with the following content:
a=#b
c="#d"
#e=f
现在运行`node -e'console.log(require("dotenv").config())'
now run `node -e 'console.log(require("dotenv").config())'
这将返回:
{ parsed: { a: '#b', c: '#d' } }
在某处可能有换行符吗?
Is there maybe a newline character somewhere?
这篇关于转义.env文件中的#字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!