SBoudrias / Inquirer.js

A collection of common interactive command line user interfaces.
MIT License
20.25k stars 1.31k forks source link

Regression in 1.5.4: SyntaxError: The requested module '@inquirer/type' does not provide an export named 'CancelablePromise' #1553

Closed johnpc closed 1 month ago

johnpc commented 1 month ago

I am using AWS Amplify's CLI tool (ampx) which is installed via npm. Since the release of @inquirer/type@1.5.4 a couple hours ago, the CLI tool is unusable:

➜  git:(main) ✗ npx ampx --help
file:///Users/xss/repo/image-host/node_modules/@inquirer/core/dist/esm/lib/create-prompt.mjs:2
import { CancelablePromise } from '@inquirer/type';
         ^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@inquirer/type' does not provide an export named 'CancelablePromise'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:191:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:336:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:106:12)

Node.js v18.19.0

I have confirmed that I am able to fix this issue by downgrading inquirer via

  "overrides": {
    "@inquirer/type": "1.5.3"
  },

Full repro steps:

$ npx create-next-app@latest temp-sep15-repo && cd temp-sep15-repo
$ npm create amplify
$ npx ampx help

file:///Users/xss/repo/temp-sep15-repo/node_modules/@inquirer/core/dist/esm/lib/create-prompt.mjs:2
import { CancelablePromise } from '@inquirer/type';
         ^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@inquirer/type' does not provide an export named 'CancelablePromise'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:191:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:336:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:106:12)

Node.js v18.19.0
SBoudrias commented 1 month ago

Thanks for the report. @inquirer/type@1.5.4 should've been a major; it's a human mistake.

It's always a bit tricky to then deal with history given the forward only nature of packages, but I think there's a fix out now.

  1. @inquirer/type@1.5.3 is republished as 1.5.5 https://www.npmjs.com/package/@inquirer/type/v/1.5.5 (content seems correct.) I don't think that'll break the in-between versions relying on 1.5.4 - but luckily those were all major, so it should reduce the radius of impact.
  2. @inquirer/type@1.5.4 is republished as 2.0.0, including patches release for all dependencies.

Lastly, I made the dependencies within this monorepo strict, so it reduces the risk of that type of issue reoccurring. Thanks for the timely report!! This bug still up Monday would've caused a lot of headache 😬😱

Note: Will still accept help migrating this repo from lerna to changeset if someone wanna start a PR.