Skip to content

Cannot find package '@aws-sdk/client-scheduler error

0

Hello,

this minimal Nodejs 18 lambda (from https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-scheduler/index.html)

import { SchedulerClient, CreateScheduleCommand } from "@aws-sdk/client-scheduler";

export const handler = async(event) => {
    // TODO implement
    const response = {
        statusCode: 200,
        body: JSON.stringify('Hello from Lambda!'),
    };
    return response;
};

leads to this error:

{ "errorType": "Error", "errorMessage": "Cannot find package '@aws-sdk/client-scheduler' imported from /var/task/index.mjs", "trace": [ "Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@aws-sdk/client-scheduler' imported from /var/task/index.mjs", " at new NodeError (node:internal/errors:393:5)", " at packageResolve (node:internal/modules/esm/resolve:865:9)", " at moduleResolve (node:internal/modules/esm/resolve:958:20)", " at moduleResolveWithNodePath (node:internal/modules/esm/resolve:909:12)", " at defaultResolve (node:internal/modules/esm/resolve:1173:79)", " at nextResolve (node:internal/modules/esm/loader:163:28)", " at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)", " at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)", " at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)", " at link (node:internal/modules/esm/module_job:75:36)" ] }

How to fix it?

Thanks

asked 3 years ago4.2K views
3 Answers
3

Same problem, please update sdk version in runtime soon! Thanks

answered 3 years ago
2
Accepted Answer

Hi,

You can see supported runtimes here: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

For node18, latest sdk version is 3.188.0.

Client-scheduler seems to be introduced in 3.208. https://github.com/aws/aws-sdk-js-v3/releases?page=6.

Thus you ll need to install it explicitly, hope it helps

EXPERT
answered 3 years ago
0

This creates a pain from being able to to exclude @aws-sdk* in CDK nodeJSFunction if using Node 18 but having to make an exception for this one library. Also want to point out that Bundling Options is also misleading in this regard. Enter image description here

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.