Cannot find module 'aws-xray-sdk' in nodejs Lambda
- Dominant language
- JavaScript
- Stars
- 280
- Forks
- 157
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to use aws-xray-sdk.
package.json has these dependencies:
"dependencies": {
"aws-sdk": "^2.1357.0",
"aws-xray-sdk": "^3.3.0"
}
Lambda function has this code:
const AWSXRay = require('aws-xray-sdk');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
I installed aws-xray-sdk using "npm install aws-xray-sdk --save" and it is installed successfully.
However, when I invoke my Lambda function I get:
"Error: Cannot find module 'aws-xray-sdk'\nRequire stack:\n- /var/task/authentication.js\n- /var/runtime/index.mjs",
Any ideas?
Contributor guide
Research direction
Start with package.json and the Lambda deployment containing authentication.js, checking whether the installed aws-xray-sdk dependency is present in the artifact that runs in Lambda. Done means the deployed function can resolve require('aws-xray-sdk') and invoke without the reported module-not-found error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript, node.js
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100