最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

dotenv没有加载.env文件

IT培训 admin 8浏览 0评论

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

否则你没有字典!

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. 暂无评论