【发布时间】:2021-09-18 07:16:40
【问题描述】:
我试图为我的机器人隐藏一个不和谐的令牌,我很确定我的 dotenv 设置正确,但我得到的只是未定义的。当我进行更改时,我什至甚至使用 nodemon 重新启动服务器。
我错过了什么吗?这是我到目前为止所尝试的。
const dotenv = require('dotenv').config();
# and
require('dotenv').config();
var token = process.env.DT;
#and
const token = process.env.DT;
DT=yourtokenhere
【问题讨论】:
-
你的
.env文件在哪里? -
它应该在我的根目录中。它就在我的 index.js 文件旁边
标签: javascript node.js dotenv