最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dotenv没有加载.env文件

运维笔记admin17浏览0评论

dotenv没有加载.env文件

dotenv没有加载.env文件

使用dotenv库,我无法从我的节点项目访问process.env变量。

index.js(入口点)

const result = require('dotenv').config()
if (result.error) {
  throw result.error
}
console.log(result.parsed)
console.log(process.env.JIRA_CONSUMER_KEY);

.ENV

JIRA_CONSUMER_KEY:bot-consumer-key

命令行输出

⇒  nodemon index.js
[nodemon] 1.12.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
{}
undefined
undefined

文件树

- icm_bot
    - index.js
    - .env
回答如下:

它等于.env文件中的冒号!

JIRA_CONSUMER_KEY=bot-consumer-key

否则你没有字典!

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论