Skip to content

amplify codegen add fails with "A dynamic import callback was not specified" error #14942

Description

@shivennn

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v18.20.8

Amplify CLI Version

14.5.0

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

Describe the bug

Running amplify codegen add --apiId <api-id> --region fails with the error "A dynamic import callback was not specified" after selecting the app type and framework. The command fails at the "Getting API details" step.

This occurs on a fresh Create React App project without amplify init having been run. The error also reproduces on Node.js v24.17.0.

Expected behavior

The command should successfully connect to the AppSync API and proceed with codegen configuration as described in AppSync API Console.

Image

Reproduction steps

  1. Create a new React app:
   npx create-react-app test-app-schema-test
   cd test-app-schema-test
  1. Run codegen add with an existing AppSync API:

amplify codegen add --apiId <api-id> --region

  1. Select "javascript" for app type
  2. Select "react" for framework
  3. Command fails with: "A dynamic import callback was not specified."

Tested on both Node.js v18.20.8 and v24.17.0 — same result.

Project Identifier

amplify diagnose --send-report

⚠️ WARNING: AWS Amplify Gen 1 CLI is in maintenance mode and will reach end of life on May 1, 2027.
During maintenance mode, only critical bug fixes and security patches will be provided.
Migrate to Amplify Gen 2: https://docs.amplify.aws/react/start/migrate-to-gen2/

Learn more at https://docs.amplify.aws/cli/reference/diagnose/
⠋ Creating Zip
No Amplify backend project files detected within this folder.
✖ Creating Zip

Log output

Details
⚠️  WARNING: AWS Amplify Gen 1 CLI is in maintenance mode and will reach end of life on May 1, 2027.
During maintenance mode, only critical bug fixes and security patches will be provided.
Migrate to Amplify Gen 2: https://docs.amplify.aws/react/start/migrate-to-gen2/

? Choose the type of app that you're building javascript
? What javascript framework are you using react
✖ Getting API details
A dynamic import callback was not specified.


Additional information

  • The --debug flag does not provide additional stack trace information beyond the error message.
  • Would be helpful if the CLI provided a more descriptive error message indicating the root cause (e.g., missing Amplify initialization, plugin loading failure, etc.).

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

Workaround

Option A: Download schema via AWS CLI

  1. Download the schema from AppSync:
    aws appsync get-introspection-schema --api-id --region eu-west-2 --format SDL schema.graphql

  2. Place the schema.graphql file in the root of the project.

  3. Run codegen without --apiId:
    amplify codegen add

Option B: Manually place schema file

  1. Copy or create your "schema.graphql" file in the root of the project (e.g., export it from the AppSync console).

  2. Run codegen without --apiId:
    amplify codegen add

  3. Follow the prompts:
    ? Choose the type of app that you're building: javascript
    ? What javascript framework are you using: react
    ? Choose the code generation language target: javascript
    ? Enter the file name pattern of graphql queries, mutations and subscriptions: src/graphql/**/*.js
    ? Do you want to generate/update all possible GraphQL operations - queries, mutations and subscriptions: Yes
    ? Enter maximum statement depth: 2
    ✔ Generated GraphQL operations successfully and saved at src/graphql

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions