@karmaniverous/get-dotenv
    Preparing search index...

    Function getDotenv

    • Asynchronously process dotenv files of the form .env[.<ENV>][.<PRIVATE_TOKEN>]

      Type Parameters

      Parameters

      Returns Promise<Vars>

      The combined parsed dotenv object. *

      const vars = await getDotenv();
      console.log(vars.MY_SETTING);
      const vars = await getDotenv({
      env: 'dev',
      dotenvToken: '.testenv',
      privateToken: 'secret',
      paths: ['./', './packages/app'],
      });
      // .env.js default-exports: { DYNAMIC: ({ PREV }) => `${PREV}-suffix` }
      const vars = await getDotenv({ dynamicPath: '.env.js' });
      • When loadProcess is true, the resulting variables are copied into process.env as a side effect (an undefined value, or a key a dynamic null deleted, deletes the key). It defaults to false: getDotenv() does not touch process.env unless asked to.
      • When outputPath is provided, a consolidated dotenv file is written. The path is resolved after expansion, so it may reference previously loaded vars. Each value is quoted and escaped as needed so that dotenv reads the file back to the result.

      Error when a dynamic module is present but cannot be imported.

      Error when an output path was requested but could not be resolved.

      Error when an output value can't be written so that dotenv reads it back unchanged (the message names the key).

    • Asynchronously process dotenv files of the form .env[.<ENV>][.<PRIVATE_TOKEN>]

      Type Parameters

      Parameters

      Returns Promise<ProcessEnv & Vars>

      The combined parsed dotenv object. *

      const vars = await getDotenv();
      console.log(vars.MY_SETTING);
      const vars = await getDotenv({
      env: 'dev',
      dotenvToken: '.testenv',
      privateToken: 'secret',
      paths: ['./', './packages/app'],
      });
      // .env.js default-exports: { DYNAMIC: ({ PREV }) => `${PREV}-suffix` }
      const vars = await getDotenv({ dynamicPath: '.env.js' });
      • When loadProcess is true, the resulting variables are copied into process.env as a side effect (an undefined value, or a key a dynamic null deleted, deletes the key). It defaults to false: getDotenv() does not touch process.env unless asked to.
      • When outputPath is provided, a consolidated dotenv file is written. The path is resolved after expansion, so it may reference previously loaded vars. Each value is quoted and escaped as needed so that dotenv reads the file back to the result.

      Error when a dynamic module is present but cannot be imported.

      Error when an output path was requested but could not be resolved.

      Error when an output value can't be written so that dotenv reads it back unchanged (the message names the key).