Trying to package node code for an AWS lambda function with lambda@edge, and running into an error.
Module not found: Error: Can't resolve 'aws-jwt-verify/error'
Typescript compiles successfully with TSC, but webpack throws this error during bundling. Here are the packages and webpack configurations used:
"devDependencies": {
"@types/aws-lambda": "^8.10.121",
"@types/cookie": "^0.5.2",
"@types/node": "^20.6.2",
"aws-sdk": "^2.1459.0",
"html-loader": "^2.1.2",
"ts-loader": "^8.2.0",
"typescript": "^4.0.0",
"webpack": "^4.47.0",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"aws-jwt-verify": "^4.0.0",
"aws-lambda": "^1.0.7",
"cookie": "^0.5.0",
"fs": "0.0.2",
"sass-loader": "^10.4.1"
}
webpack.config.js
const path = require('path');
module.exports = {
entry: './index.ts',
module: {
rules: [
{
test: /\.html$/,
use: 'html-loader'
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
}
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, './'),
libraryTarget: 'commonjs',
},
target: 'node',
devtool: 'source-map'
};