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.

(lambda-nodejs): add support for monorepos

See original GitHub issue

What is the problem?

Rolling my codebase up in a monorepo, I found that trying to build a NodejsFunction, I get the following error:

Usage Error: Couldn't find a script named "esbuild".

I’m using the following settings in .yarnrc.yml, which hoists all my node_modules to my monorepo root:

nmMode: hardlinks-global
nodeLinker: node-modules

Reproduction Steps

Here’s a repro.

What did you expect to happen?

I expected it to work.

What actually happened?

Usage Error: Couldn't find a script named "esbuild".

CDK CLI Version

2.3.0 (build beaa5b2)

Framework Version

2.3.0

Node.js Version

v14.18.1

OS

OSX 12.0.1 (21A559)

Language

Typescript

Language Version

4.5.4

Other information

Happy holidays! 😁

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
blimmercommented, Dec 29, 2021

I’ve encountered this error before, as well. It’s a bit confusing, but you need to have esbuild in your root package.json file, not in your packages/aws/package.json file. I tested this on your repro repository and it works (see https://github.com/mikestopcontinues/cdk-mono-yarn-esbuild-issue/pull/1).

1reaction
vleanderssoncommented, Jul 15, 2022

@blimmer yeah, I saw that. Great insights. Thanks! Sadly nodeLinker: node-modules will turn off pnp, but I guess we got to live with that till we get pnp support added 🤷

Read more comments on GitHub >

github_iconTop Results From Across the Web

NodeJS mono repository with multiple AWS lambdas
First, we need to add aws-lambda dependencies to our project. $ npm i aws-lambda $ npm i -D @types/aws-lambda.
Read more >
Optimizing Node.js dependencies in AWS Lambda
AWS Lambda offers support for Node.js versions 12, ... Node.js reads and parses all dependencies and sources that are required or imported ...
Read more >
AWS Lambda Monorepo - Node.js - Daniel Broadhurst
A monorepo is a single repository which stores all the code for multiple independent projects. It can be used to create a single...
Read more >
AWS Lambda: how to share code in a monorepo
... can I share business logic between services in a Node.js monorepo?”. ... you need to know to use AWS Step Functions service...
Read more >
🚀 The Ultimate Monorepo Starter for Node.js Serverless ...
js Serverless Applications.” Features. ✓ First-Class Typescript Support ✓ DynamoDB Single Table Design ✓ Shared API Gateway ✓ Environments Configuration ✓ ...
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