-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(@aws-cdk/aws-lambda-nodejs): "error: Could not resolve" while bundling without Docker #12115
Comments
Can you show the content of the file at Also can you share the full stack trace of the error? |
@jogold, the "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const datadog_lambda_js_1 = require("datadog-lambda-js");
const dd_trace_1 = __importDefault(require("dd-trace"));
const processIncomingEvent_1 = __importDefault(require("./processIncomingEvent"));
dd_trace_1.default.init();
exports.main = datadog_lambda_js_1.datadog(processIncomingEvent_1.default);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSx5REFBNEM7QUFDNUMsd0RBQThCO0FBQzlCLGtGQUEwRDtBQUUxRCxrQkFBTSxDQUFDLElBQUksRUFBRSxDQUFDO0FBRWQsT0FBTyxDQUFDLElBQUksR0FBRywyQkFBTyxDQUFDLDhCQUFvQixDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBkYXRhZG9nIH0gZnJvbSAnZGF0YWRvZy1sYW1iZGEtanMnO1xuaW1wb3J0IHRyYWNlciBmcm9tICdkZC10cmFjZSc7XG5pbXBvcnQgcHJvY2Vzc0luY29taW5nRXZlbnQgZnJvbSAnLi9wcm9jZXNzSW5jb21pbmdFdmVudCc7XG5cbnRyYWNlci5pbml0KCk7XG5cbmV4cG9ydHMubWFpbiA9IGRhdGFkb2cocHJvY2Vzc0luY29taW5nRXZlbnQpO1xuIl19 Here's the stack trace I get when running
|
What happens if you point your entry to the Can you please share the full console output of the error from |
Pointing to the $ cdk synth
Bundling asset FooStack/FooLambda/MyLambda/Code/Stage...
> error: Could not resolve "../lambda/src/index.ts"
1 error
Failed to bundle asset FooStack/FooLambda/MyLambda/Code/Stage, bundle output is located at /Users/sbassin/Development/my-project/cdk/cdk.out/bundling-temp-d9c47ce4518849903f729fa37b1175435ea4dc7ce04d627c791c0fb3fb76f676-error: Error: bash exited with status 1
Subprocess exited with error 1
Error: Subprocess exited with error 1
at ChildProcess.<anonymous> (/Users/sbassin/.nvm/versions/node/v12.20.0/lib/node_modules/cdk/node_modules/aws-cdk/lib/api/cxapp/exec.ts:122:23)
at ChildProcess.emit (events.js:314:20)
at ChildProcess.EventEmitter.emit (domain.js:483:12)
at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12) Is that what you're looking for, @jogold? And there's nothing in the directory indicated as the location of the bundle output. I appreciate the help! |
If this doesn't work, it would help if you could share a full repro. |
Can you also test with absolute paths? |
I changed to:
but got the same error. I just saw your edit about absolute paths and tried that. I haven't confirmed if I can deploy a working Lambda that way, but I did get Please let me know if there's anything else you'd like me to try on my end. If you want a full repository, I'll have a bit of sanitizing to do. |
Can you just confirm which of the paths must be absolute? Is it |
Also note that the idea of the |
Looks like only For what it's worth, I was actually able to run I'm curious what the project organization would look like if I don't split the project. Possibly this?
One concern I'd have about merging them would be if I want different versions of Node.js or TypeScript in the Lambda from what CDK itself supports. I'm pretty new to JS/TS and CDK, so I'm not sure if that's a valid concern, though. |
Ensure it's a file and make it absolute. Closes aws#12115
I recommend the approach described in https://github.com/aws/aws-cdk/blob/v1.78.0/packages/@aws-cdk/aws-lambda-nodejs/README.md#nodejs-function where your handler lives next to the file where the If everything lives together you can share utils and types between your infra code and Lambda code. (also you don't have to specify |
|
Thanks for the help and the fix, @jogold! 🙇♂️ |
I'm trying to bundle my Lambda using
NodejsFunction
but am failing. If I setforceDockerBundling
totrue
(default isfalse
), bundling (duringcdk synth
) is successful.Reproduction Steps
For what it's worth, my project is structured like:
What did you expect to happen?
I expected the Lambda and (hopefully) its dependencies would be packaged using
esbuild
.What actually happened?
Environment
Other
I've tried setting the
entry
to a file that doesn't exist, and I get a different error altogether. So I'm pretty sure that the file is being found, but some other problem is happening.This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: