app.js
import koa from 'koa';
import http from 'http';
import logger from 'koa-logger';
import koaBody from 'koa-body';
import dotenv from 'dotenv';
import dotenvExpand from 'dotenv-expand';
const config = dotenv.config();
dotenvExpand(config);
console.log(process.env); // Here I see all data which are in my .env file
import { client } from '@pg'; // Inside this file I doesn't see this,but it still after initializing dotenv
@pg = db / connection / index.js
import { Client } from 'pg';
console.log(process.env.DATABASE_URL,'fds'); // here I don't see the same ( all variables from .env file are undefined)
export const client = new Client({
connectionString: process.env.DATABASE_URL
});
如果您需要其他信息,请告诉我。请注意我在代码段中的注释,这可能会有所帮助