aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
166 stars 55 forks source link

Error: @inquirer/type does not provide 'CancelablePromise' when running npm create amplify@latest #2015

Closed Julianrvillamil closed 1 week ago

Julianrvillamil commented 1 week ago

How did you install the Amplify CLI?

npm

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

v20.17.0

Amplify CLI Version

12.12.6

What operating system are you using?

Windows (WSL)

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

No manual changes made

Describe the bug

I'm encountering an issue when trying to run the command npm create amplify@latest. The error I receive is:


import { CancelablePromise } from '@inquirer/type';
         ^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@inquirer/type' does not provide an export named 'CancelablePromise'

This error occurs after updating Node.js to version 20.17.0 and reinstalling all dependencies. The issue seems to be related to the Amplify CLI depending on an incompatible version of the @inquirer/type package.

I also tried installing both @inquirer/core and @inquirer/type manually, but the error persists.

Expected behavior

When I run the command npm create amplify@latest, I expect the process to proceed without errors. Specifically, the Amplify CLI should guide me through the setup process for configuring a new Amplify project or adding a backend to my existing frontend application. This should include prompts for setting up authentication, API, storage, or other Amplify services, without encountering issues related to the @inquirer/type or CancelablePromise.

Reproduction steps

  1. create a new nextJS project
  2. run npm create amplify@latest

Project Identifier

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

``` # Put your logs below this line ```

Additional information

No response

Before submitting, please confirm:

ykethan commented 1 week ago

Hey,👋 thanks for raising this! I'm going to transfer this over to our backend repository as the issue appears to be a Gen 2 issue.

johnpc commented 1 week ago

This was caused by a regression in the inquirer library, see https://github.com/SBoudrias/Inquirer.js/issues/1553

You should be able to work around it by adding an override to your package.json like this:

  "overrides": {
    "@inquirer/type": "1.5.3"
  },
Julianrvillamil commented 1 week ago

Hi, I have followed the suggested workaround by overriding the @inquirer/type version to 1.5.3, but I’m still facing the same issue when running npx create-amplify@latest.

After some debugging, I tested @inquirer/core and @inquirer/type by creating a simple script to see if the problem was isolated, but the issue persists. Here's the error I continue to get:

import { CancelablePromise } from '@inquirer/type';
^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@inquirer/type' does not provide an export named 'CancelablePromise'

Additionally, I installed inquirer@8 separately, and it works perfectly fine in my local environment, suggesting that the problem lies within how create-amplify is handling its dependencies.

I’m wondering if this is related to the specific versions of Node.js or npm, or if the latest releases of @inquirer/type or @inquirer/core are still incompatible with how the Amplify CLI is managing them.

Could you provide guidance on which versions of @inquirer/core and @inquirer/type work best with npx create-amplify? I’m open to trying other versions if that could solve the issue.

Environment details:

Thank you for your help!

Julianrvillamil commented 1 week ago

Update: Issue Resolved

I was able to resolve the issue with npx create-amplify@latest. Here's what I did:

  1. Cleared the npx cache: I ran the following command to clear the npx cache:

    rm -rf ~/.npm/_npx
    
  2. Installed necessary dependencies: After clearing the cache, I ensured that all dependencies were correctly installed by running:

    npm install
    
  3. Ran npx create-amplify@latest: Finally, I was able to successfully run the command, which prompted me to install the create-amplify@1.0.5 package:

    npx create-amplify@latest
    

This cleared up the issue with the @inquirer/type and the CancelablePromise error I was encountering.

Thanks for the guidance and help!