{"record":{"id":"0df64992b5ff8c95","repo":"serverless/serverless","slug":"handler-file-was-not-found-handlerfileabsolutep","errorCode":null,"errorMessage":"Handler file was not found: ${handlerFileAbsolutePath}","messagePattern":"Handler file was not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/serverless/lib/plugins/aws/dev/local-lambda/runtime-wrappers/node.js","lineNumber":107,"sourceCode":"  const filePath = path.join(os.tmpdir(), `sls_${process.pid}.json`)\n\n  const stringifiedResult = JSON.stringify(result, null, 2)\n\n  fs.writeFileSync(filePath, stringifiedResult)\n}\n\n/**\n * Imports the user handler function from the specified file path.\n * This supports both CommonJS and ESM handler files.\n *\n * @param {string} handlerFileAbsolutePath - Path to handler file\n * @param {string} handlerName - The Handler Name defined in the config file\n * @returns {Promise<Function>}\n */\nconst importFunction = async (handlerFileAbsolutePath, handlerName) => {\n  // Check if the file exists\n  if (!fs.existsSync(handlerFileAbsolutePath)) {\n    throw new Error(`Handler file was not found: ${handlerFileAbsolutePath}`)\n  }\n\n  // Convert the file path to a file URL to ensure\n  // it works across different operating systems\n  // and for both CommonJS and ESM handler files\n  const fileUrl = pathToFileURL(handlerFileAbsolutePath).href\n\n  // Import the handler file. This works for both CommonJS and ESM handler files\n  const handlerFunction = (await import(fileUrl))[handlerName]\n\n  // Make sure the handler is a function\n  if (typeof handlerFunction !== 'function') {\n    throw new Error(`Handler is not a function`)\n  }\n\n  // return the function to be invoked\n  return handlerFunction\n}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/serverless/serverless/blob/b9d7ea51c8cce57cff1207964b9b71123673081f/packages/serverless/lib/plugins/aws/dev/local-lambda/runtime-wrappers/node.js#L89-L125","documentation":"Error \"Handler file was not found: ${handlerFileAbsolutePath}\" thrown in serverless/serverless.","triggerScenarios":"Thrown at packages/serverless/lib/plugins/aws/dev/local-lambda/runtime-wrappers/node.js:107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the handler file path in the function configuration and that the file exists at that location."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b9d7ea51c8cce57cff1207964b9b71123673081f","analyzedAt":"2026-08-13T04:14:40.386Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}