[英]How to import config module following ES6 standard not commonJS
我正在混合一些進口產品,我想讓它們都使用 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');
我想對我使用 commonJS 的配置模塊使用相同的方式,ES6。
我用它來檢索一些信息:config.get('item'),
有可能這樣做嗎? 謝謝!
只需添加這一行dotenv.config();
然后您可以使用.env
文件中的值使用解構來獲取您的 env 值。
目前沒有其他辦法。 我檢查了很多網站。 謝謝你們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.