Skip to content

sandbox [TypeError] constructFactory.getInstance

0

Not sure how to resolve this TypeError. Not really seeing any syntax errors in IDE.

1:30:28 PM [ERROR] [BackendBuildError] Unable to deploy due to CDK Assembly Error ∟ Caused by: [_AssemblyError] Assembly builder failed ∟ Caused by: [TypeError] constructFactory.getInstance is not a function Resolution: Check the Caused by error and fix any issues in your backend code 1:30:28 PM Stack Trace for BackendBuildError

asked a year ago439 views

1 Answer
0

The error you're encountering suggests a problem with the lru-cache module, which is likely causing issues with the AWS CDK deployment process. This error can occur due to version incompatibilities or incorrect module resolution. Here are some steps you can try to resolve the issue:

  1. Update the lru-cache package: In your root package.json, you've already specified an override for lru-cache to version 10.0.1. Make sure this override is applied correctly by running pnpm install again.

  2. Clear your node_modules and reinstall: Run the following commands in your project root:

    pnpm clean
    pnpm install
    
  3. Check for conflicting versions: Ensure that there are no conflicting versions of lru-cache in your dependencies. You can use pnpm list lru-cache to check for any duplicate installations.

  4. Update AWS CDK and related packages: Make sure you're using the latest compatible versions of AWS CDK and related packages. Update them if necessary.

  5. Verify TypeScript configuration: Ensure that your tsconfig.json files (both root and amplify) are correctly configured, especially the moduleResolution setting. For the root tsconfig.json, try changing "moduleResolution": "bundler" to "moduleResolution": "node".

  6. Check for circular dependencies: Review your code for any potential circular dependencies, as these can sometimes cause unexpected errors during the build process.

  7. Verify Node.js version: Ensure you're using a Node.js version compatible with your project dependencies. Your package.json specifies Node.js 22.0.0, which is quite recent. Consider using an LTS version like 18.x or 20.x if you continue to have issues.

If these steps don't resolve the issue, you may need to investigate further by examining the full stack trace and potentially reaching out to AWS Amplify support for more specific guidance.

Sources
Troubleshoot circular dependency issues - AWS Amplify Gen 2 Documentation
Troubleshoot "Stack CDKToolkit already exists" - React - AWS Amplify Gen 2 Documentation

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.