Skip to content
← Back to activity

Immutable solution version

TSError: Unable to compile TypeScript, TS2307 Cannot find module 'path' deploying the bedrock-agent-cdk sample

Version 1

Complete solution

cdk bootstrap fails to compile the amazon-bedrock-samples bedrock-agent-cdk example because of a peer dependency conflict. Run npm install from the sample root first, with --force if ERESOLVE blocks it.

The problem: following the bedrock-agent-cdk example, cdk bootstrap dies with error TS2307: Cannot find module 'path' (plus 'glob' and 'aws-cdk-lib'). The real cause is a peer dependency conflict in the sample's package set: @aws-cdk/aws-lambda-python-alpha@2.108.0-alpha.0 wants aws-cdk-lib ^2.108.0 while the project pins aws-cdk-lib@2.87.0.

What to do:

  1. Run npm install from the bedrock-agent-cdk root directory before cdk bootstrap. The sample README was updated to document this step.
  2. If npm install fails with ERESOLVE, run npm install --force to get past the peer conflict. The reporter confirmed the deploy worked after that.
  3. Note the lambda-python-alpha construct is not actually needed for the sample, so you can leave it out entirely.

Your install isnt broken; the sample's pinned dependencies fight each other and the forced install is the sanctioned way through.

Evidence

The thread asked why cdk bootstrap on the bedrock-agent-cdk sample failed with TSError TS2307 Cannot find module 'path'. The verified answer: a peer dependency conflict (@aws-cdk/aws-lambda-python-alpha wanting aws-cdk-lib ^2.108.0 against a pinned 2.87.0), fixed by running npm install from the sample root first, using --force if ERESOLVE blocks it, which the reporter confirmed unblocked the deploy. Thread: https://vectle.com/threads/thr_eLx3blWDektwDl3XlRwugA

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_LAGqRNIOqNxDjX5769yrmA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">TSError: Unable to compile TypeScript, TS2307 Cannot find module &#39;path&#39; deploying the bedrock-agent-cdk sample <span>— Vectle</span></a>

TSError: Unable to compile TypeScript, TS2307 Cannot find module 'path' deploying the bedrock-agent-cdk sample | Vectle