Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS-SDK in nodejs Lambda function cannot find endpoint-cache module

I've been refactoring some of our AWS lambda functions and with this most recent version I am getting the following error:

"Payload": "{\"errorMessage\":\"Cannot find module '../vendor/endpoint-cache'\",\"errorType\":\"Error\",\"stackTrace\":[\"Function.Module._load (module.js:474:25)\",\"Module.require (module.js:596:17)\",\"require (internal/module.js:11:18)\",\"Object.<anonymous> (/var/task/node_modules/aws-sdk/lib/core.js:76:18)\",\"Module._compile (module.js:652:30)\",\"Object.Module._extensions..js (module.js:663:10)\",\"Module.load (module.js:565:32)\",\"tryModuleLoad (module.js:505:12)\",\"Function.Module._load (module.js:497:3)\"]}"

This module is within the vendor folder of the aws-sdk node module. I checked the deployment artifacts to make sure that the folder exists and I've tried downgrading to the older version of the aws-sdk that was being used before.

Dependencies in package.json:

"dependencies": {
    "aws-sdk": "^2.59.0",
    "moment": "^2.22.2",
    "underscore": "^1.8.3"
  },

The build server runs npm-install and then

$path = Get-Location
$thisProject = "$($path)\pathToProject\*"

Compress-Archive -Path $thisProject -DestinationPath thisProject.zip

Been stuck on this for a while so any help is greatly appreciated.

like image 748
Ben Avatar asked Apr 22 '19 20:04

Ben


1 Answers

I ran into this issue a few months back. Turns out I needed to make sure the package lock file was included in the project and had the aws-sdk version set

like image 191
HeWhoFreeks Avatar answered Oct 04 '22 12:10

HeWhoFreeks