question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[@aws-cdk/aws-lambda-nodejs] 'Cannot find entry file' when using a JSII construct that includes a lambda_nodejs.NodejsFunction

See original GitHub issue

I’m trying to create a reusable library to handle ECR image scan results. The code is available at https://github.com/markusl/cdk-ecr-image-scan-handler

After publishing the generated library (using projen & JSII tools) to NPM and using it from another AWS CDK project I get the following, not very useful error message:

$ npm run build && cdk synth

> aws-cdk-pipelines-test@0.1.0 build aws-cdk-pipelines-test
> tsc

Cannot find entry file.
Subprocess exited with error 1

The directory structure of the imported NPM package under node_modules looks ok to me:

cdk-ecr-image-scan-handler/lib/index.js
cdk-ecr-image-scan-handler/lib/index.d.ts
cdk-ecr-image-scan-handler/lib/index.handler.js
cdk-ecr-image-scan-handler/lib/index.handler.d.ts

@jogold already provided some input for the source module setup which apparently is supposed to work like this:

new lambda_nodejs.NodejsFunction(this, 'handler', {
      runtime: lambda.Runtime.NODEJS_12_X,
      minify: true,
      role: lambdaRole,
      functionName: componentName,
      description: 'Handler for ECR Image Scan results',
      environment: {
        FROM_ADDRESS: props.fromAddress,
        TO_ADDRESS: props.toAddress,
      },
    });

Please let me know if there are any configuration errors in the project. I was looking for a reference setup but did not find one yet.

What did you expect to happen?

I would expect the Lambda function to be packaged correctly.

What actually happened?

I received the error.

Environment

  • CLI Version : 1.59.0
  • Framework Version: 1.59.0
  • Node.js Version: v12.14.1
  • OS : macOS
  • Language (Version):

Other


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
markuslcommented, Aug 17, 2020

@jogold we are also considering creating some internal libraries/tooling which require the bunding functionality. If we get this working 😃 I’d like to start with a simple example first to get the baseline configuration working.

Would you be able to provide a complete JSII module with an example setup using NodejsFunction bundling? That would be a good starting point for us and others as well.

1reaction
jogoldcommented, Aug 20, 2020

@markusl switching to local bundling in your repo (https://github.com/markusl/cdk-ecr-image-scan-handler/pull/28, https://github.com/markusl/cdk-ecr-image-scan-handler/pull/29) made it work in your GitHub action.

It looks like Docker-in-Docker with volume mounts inside a GitHub action is problematic but we now have local bundling.

Regarding the Cannot find entry file I think we can improve the automatic entry finding in the CDK. There’s something to do with the source map.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class NodejsFunction (construct) · AWS CDK
entry ? Type: string (optional, default: Derived from the name of the defining file and the construct's id. If the NodejsFunction is defined...
Read more >
Converting a CDK construct to using Projen
I'm going to cover here what it took to convert an existing JSII-based CDK construct, nightynight. The Existing Code. First, a quick review...
Read more >
aws-cdk/aws-lambda-nodejs
This library provides constructs for Node.js Lambda functions. To use this module, you will need to have Docker installed. Node.js Function.
Read more >
Cannot deploy Nodejs and Typescript to AWS cdk + lambda
I'm beginner of aws cdk + lambda. I tried to deploy my code but i saw this error. => [internal] load build definition...
Read more >
@aws-cdk/aws-lambda-nodejs | Yarn - Package Manager
This library provides constructs for Node.js Lambda functions. Node.js Function. The NodejsFunction construct creates a Lambda function with automatic ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found