I have been trying to get the node-fetch module in a CDK project. So that i can use it in a Lambda function.
The dependency is in the package.json file.
I installed it in the node package manager.
I keep getting: Cannot find module 'node-fetch.
I have looked at: https://github.com/node-fetch/node-fetch/issues/1027 But this didn't seem to work.
Function definition:
const lambdaJiraApi = new lambda.Function(this, 'lambda_Jira_api', {
runtime: lambda.Runtime.NODEJS_16_X,
code: Code.fromAsset('lambda'),
handler: 'apiJiraFetcher.handler',
timeout: Duration.seconds(20),
functionName: 'lambda_Jira_api',
environment: { QUEUEURL: queueSQS.queueUrl },
layers: [nodeFetchLayer],
});
var fetch = require("node-fetch");