Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: populate() is not a function #830

Open
marigarey opened this issue Jun 16, 2024 · 3 comments
Open

Bug: populate() is not a function #830

marigarey opened this issue Jun 16, 2024 · 3 comments

Comments

@marigarey
Copy link

When I use the populate function, my code returns the error: "TypeError: dotenv.populate is not a function".

My code:

const parsed = {TEST: 'test'}
dotenv.populate(process.env, parsed)

Not sure what is wrong, hopefully its on my end!

@marigarey marigarey changed the title populate() is not a function Bug: populate() is not a function Jun 16, 2024
@motdotla
Copy link
Owner

it probably just hasnt been added to the types file. dotenv has never been a typescript project. you can either define your own type in your project for it or if you have time a PR contribution to add it to the project's type file would be very welcome :)

@marigarey
Copy link
Author

i've been using javascript, but I can try to look through the code and see how to fix it!

(also thank you for your dotenv work! your work makes my life so much easier!!)

@mrinal-c
Copy link

mrinal-c commented Jul 4, 2024

Hi, I am a programmer trying to get into open-source contribution and wanted to chime in here. It seems like populate is already defined in the lib/main.d.ts types file:

/**
 * Loads `source` json contents into `target` like process.env.
 *
 * See https://dotenvx.com/docs
 *
 * @param processEnv - the target JSON object. in most cases use process.env but you can also pass your own JSON object
 * @param parsed - the source JSON object
 * @param options - additional options. example: `{ debug: true, override: false }`
 * @returns {void}
 *
 */
export function populate(processEnv: DotenvPopulateInput, parsed: DotenvPopulateInput, options?: DotenvConfigOptions): void;

Not sure if I'm looking in the right place, maybe it's a config issue on the user's end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants