使用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);
Run Code Online (Sandbox Code Playgroud)
.ENV
JIRA_CONSUMER_KEY:bot-consumer-key
Run Code Online (Sandbox Code Playgroud)
命令行输出
? nodemon index.js
[nodemon] 1.12.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
{}
undefined
undefined
Run Code Online (Sandbox Code Playgroud)
文件树
- icm_bot
- index.js
- .env
Run Code Online (Sandbox Code Playgroud)
它等于.env文件中的冒号!
JIRA_CONSUMER_KEY=bot-consumer-key
Run Code Online (Sandbox Code Playgroud)
否则你没有字典!
| 归档时间: |
|
| 查看次数: |
270 次 |
| 最近记录: |