admin管理员组文章数量:1296461
I added one key variable in .env file in nodeJS application as below.
KEY="---Key---
..............
..............
"
When i try to get this variable from .env it got only "---Key---". I don't know why.
I added one key variable in .env file in nodeJS application as below.
KEY="---Key---
..............
..............
"
When i try to get this variable from .env it got only "---Key---". I don't know why.
Share Improve this question asked Apr 11, 2018 at 7:01 Kishan DobariyaKishan Dobariya 731 silver badge7 bronze badges 1- 2 Please read the documentation: github./motdotla/dotenv#rules – str Commented Apr 11, 2018 at 7:03
2 Answers
Reset to default 6You cannot put your env variable on multiple lines.
Just write it on one line, using double quotes, and use \n
in between lines.
You can see it here: https://github./motdotla/dotenv#rules
If you want multiple line string on env variable, you need to use \n
wherever new line requires. Please see the example below.
index.js
require('dotenv').config();
console.log(process.env.TEST);
.env
TEST="Hi! how are you? \n I am fine."
out put
Hi! how are you?
I am fine.
本文标签: javascriptString not readable after newline from env in nodeJsStack Overflow
版权声明:本文标题:javascript - String not readable after newline from .env in nodeJs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741631042a2389366.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论