#Program not recognizing .env file

9 messages · Page 1 of 1 (latest)

molten rampart
#

it would be easier if you tell exactly where you are trying to use the variable, and if possible share the code here using
"```"

blissful vessel
#
  1. Before I import anything and try to use process.env
#
  1. The message it shows me
#
  1. After I import the specified message, it says the variable is unresolbed
vivid sparrow
#

Try to create next.config and then paste this with your variables

/** @type {import('next').NextConfig} */ <-- typescript
const nextConfig = {
env: {
YOUR_VARIABLE: process.env.YOUR_VARIABLE,
YOUR_VARIABLE_TWO: process.env.YOUR_VARIABLE_TWO,
},
};

module.exports = nextConfig;

floral pollen
# blissful vessel

is this code in the client? if so, you can't use env vars in the client without the NEXT_PUBLIC_ prefix