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 1Sign in to save

Complete solution

Teaches the verified fix from a real amazon-bedrock support thread: tSError: Unable to compile TypeScript, TS2307 Cannot find module 'path' deploying the bedrock-agent-cdk sample

What this fixes

A user following the bedrock-agent-cdk example in amazon-bedrock-samples hit a wall running cdk bootstrap. TypeScript refused to compile: error TS2307 Cannot find module 'path' (plus 'glob' and 'aws-cdk-lib'). They had already run npm install in the sample root, but it died with an ERESOLVE peer dependency conflict: @aws-cdk/aws-lambda-python-alpha@2.108.0-alpha.0 requires aws-cdk-lib ^2.108.0 while the project pinned aws-cdk-lib@2.87.0. Context: the bedrock-agent-cdk CDK example, CDK v2.

The fix

This is a peer dependency conflict in the sample's package set, not a broken install on your side. First run npm install from the bedrock-agent-cdk root directory before cdk bootstrap. If npm install fails with ERESOLVE (aws-cdk-lib@2.87.0 vs @aws-cdk/aws-lambda-python-alpha@2.108.0-alpha.0 wanting aws-cdk-lib ^2.108.0), run npm install --force to get past it. The reporter confirmed the deploy worked after that, and the sample README was updated to document the install step. The lambda-python-alpha construct is not actually needed and can be left out. Source: https://github.com/aws-samples/amazon-bedrock-samples/issues/40

Why it happens

The thread above nails the cause, so the fix addresses that directly rather than symptoms. Adapt the version numbers and paths to your setup, then verify the behavior the thread confirmed.

Source

https://github.com/aws-samples/amazon-bedrock-samples/issues/40

Evidence

Asked in the thread (https://vectle.com/threads/thr_eLx3blWDektwDl3XlRwugA): A user following the bedrock-agent-cdk example in amazon-bedrock-samples hit a wall running cdk bootstrap. TypeScript refused to compile: error TS2307 Cannot find module 'path' (plus 'glob' and 'aws-cdk-lib'). They had already run npm install in the sample root, but it died with an ERESOLVE peer dependency conflict: @aws-cdk/aws-lambda-python-alpha@2.108.0-alpha.0 requires aws-cdk-lib ^2.108.0 while the project pinned aws-cdk-lib@2.87.0. Context: the bedrock-agent-cdk CDK example, CDK v2. Verified resolution: This is a peer dependency conflict in the sample's package set, not a broken install on your side. First run npm install from the bedrock-agent-cdk root directory before cdk bootstrap. If npm install fails with ERESOLVE (aws-cdk-lib@2.87.0 vs @aws-cdk/aws-lambda-python-alpha@2.108.0-alpha.0 wanting aws-cdk-lib ^2.108.0), run npm install --force to get past it. The reporter confirmed the deploy worked after that, and the sample README was updated to document the install step. The lambda-python-alpha construct is not actually needed and can be left out. Source: https://github.com/aws-samples/amazon-bedrock-samples/issues/40

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_yR_GQhRmzoqSReW-oGsmgA" 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