[英]How to import config module following ES6 standard not commonJS
I'm mixing some imports and I would like to have all of them using ES6.我正在混合一些进口产品,我想让它们都使用 ES6。
import express from 'express';
import dotenv from 'dotenv';
import { PasswordItemDTO } from './api/clients/PasswordCheck/model/passwordItemDTO';
import { PasswordErrorsDTO } from './api/clients/PasswordCheck/model/passwordErrorsDTO';
const config = require('config');
I would like to use the same way, ES6, for the config module which I used commonJS.我想对我使用 commonJS 的配置模块使用相同的方式,ES6。
I'm using it to retrieve some information: config.get('item'),我用它来检索一些信息:config.get('item'),
There is a possibility to do that?有可能这样做吗? Thanks!
谢谢!
Just add this line dotenv.config();
只需添加这一行
dotenv.config();
and you can then use the values in the .env
file using destructuring to get your env values.然后您可以使用
.env
文件中的值使用解构来获取您的 env 值。
There is not other way for now.目前没有其他办法。 I checked in lot of websites.
我检查了很多网站。 Thank you all.
谢谢你们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.