Lambda Functions Not Working. Failed to create output directory: Access is denied

I’m trying to solve this issue from last 2 days and was not able to solve that’s I thought connecting with forum will help me.

I’m working on React Project built with Vite with React + TS template, and I’m also using redux toolkit. My application works looks fine when I run netlify dev or ntl dev, I’m also logged in to netlify using netlify login or ntl login
And this error is produced when I hit my lambda function. Below I have attached screenshot of error, my folder structure and my lambda function code.
@hrishikesh please sir help me

export const handler = async (event) => {
  try {
    const subject = || "World";
    return {
      statusCode: 200,
      body: JSON.stringify({ message: `Hello ${subject}` }),
      // // more keys you can return:
      // headers: { "headerName": "headerValue", ... },
      // isBase64Encoded: true,
  } catch (error) {
    return { statusCode: 500, body: error.toString() };

I’d personally recommend using WSL2 if you’re developing on Windows. VSCode and WebStorm (or other IntellIj IDEs), both integrate well with WSL, so yo should not face any major issues with that.

Regarding the error though, not sure why ESBuild is trying to create a folder in C:\Users (that looks like the temp folder on your device), but on Windows, write permission to that folder requires admin check. Make sure your terminal has admin rights OR the non-recommended way would be to allow anyone to write to C:\Users.

But this is not the first time i’m using lambda functions in my system. It was working in my previous projects. Its my first time for Vite + React + TS but. And how do I install WSL2?

I don’t think it has anything to do with your stack. The esbuild error is really weird, and has no solution. It (or a similar error, I don’t remember), happened with me once on a Mac, and the only thing that worked was a device reset. Some thing probably weirdly got stuck somewhere.

WSL docs are here: Install WSL | Microsoft Learn