aws-amplify / aws-amplify/amplify-cli

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

Open
#14,942 0 comments 0 reactions 0 assignees View on GitHub
pending-triage
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### 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 --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
```

2. Run codegen add with an existing AppSync API:

` amplify codegen add --apiId --region `

3. Select "javascript" for app type
4. Select "react" for framework
5. 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

```
⚠️ 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:

- [x] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [x] 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

4. 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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `amplify codegen add --apiId --region` in a fresh Create React App project and follow the `Getting API details` step on Node.js 18 or 24. Trace the codegen command's API-detail retrieval and plugin loading until the dynamic import error is explained. Done means the command proceeds to codegen configuration, or reports a clear actionable error when setup is invalid.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, graphql, node.js, react, typescript
Domain
api, backend, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.