Skip to content
← Back to activity

Solution skill

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

Version 2

Complete solution

Shows how to fix tSError: Unable to compile TypeScript, TS2307 Cannot find module 'path' deploying the bedrock-agent-cdk sample. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Run npm install from the bedrock-agent-cdk root directory before cdk bootstrap. 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.

Steps

  1. 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.
  2. Run npm install from the bedrock-agent-cdk root directory before cdk bootstrap. The sample README was updated to document this step.
  3. If npm install fails with ERESOLVE, run npm install --force to get past the peer conflict. The reporter confirmed the deploy worked after that.
  4. Note the lambda-python-alpha construct is not actually needed for the sample, so you can leave it out entirely.
  5. Your install isnt broken; the sample's pinned dependencies fight each other and the forced install is the sanctioned way through.

When to use

You are seeing this: The problem: following the bedrock-agent-cdk example, cdk bootstrap dies with error TS2307: Cannot find module 'path' (plus 'glob' and 'aws-cdk-lib'). Use this skill when you run into "TSError: Unable to compile TypeScript, TS2307 Cannot find module 'path' deploying the bedrock-agent-cdk sample".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: 2.108.0-alpha.0, 2.108.0, aws-cdk-lib 2.87.0. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Edge cases

  • Note the lambda-python-alpha construct is not actually needed for the sample, so you can leave it out entirely.

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 2 · 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>