Skip to content

Let users skip official modules installation #922

@arun-mani-j

Description

@arun-mani-j

Hii.

Whenever we create a new Nuxt project through npm create nuxt <name>, at somewhere near final step, it asks us to choose if we want to install any of the official modules.
Though it's a great addition, the UX offered through this is very confusing. Especially, how do I skip installing any of those given modules?

If I press Esc, it fails with error. So I browsed the source code and found that we are using consola for the prompt and consola's docs say:

await prompt(message, { type, cancel })
Show an input prompt. Type can either of text, confirm, select or multiselect.
If prompt is canceled by user (with Ctrol+C), default value will be resolved by default. This strategy can be configured by setting { cancel: "..." } option:

"default" - Resolve the promise with the default value or initial value.
"undefined" - Resolve the promise with undefined.
"null" - Resolve the promise with null.
"symbol" - Resolve the promise with a symbol Symbol.for("cancel").
"reject" - Reject the promise with an error.

So it says Ctrol+C, I tried that and it also fails with error. I jumped to Nuxt's usage again and found that https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/init.ts#L306 has:

      const wantsUserModules = await logger.prompt(
        `Would you like to install any of the official modules?`,
        {
          type: 'confirm',
          cancel: 'reject',
        },
      ).catch(() => process.exit(1))

So our behavior for cancel is reject, which in causes the process to exit with non-zero return code.

❯ Would you like to install any of the official modules?
◻ @nuxt/content – The file-based CMS with support for Markdown, YAML, JSON
◻ @nuxt/eslint – Project-aware, easy-to-use, extensible and future-proof ESLint integration
◻ @nuxt/fonts – Add custom web fonts with performance in mind
◻ @nuxt/icon – Icon module for Nuxt with 200,000+ ready to use icons from Iconify
◻ @nuxt/image – Add images with progressive processing, lazy-loading, resizing and providers support
◻ @nuxt/scripts – Add 3rd-party scripts without sacrificing performance
◻ @nuxt/test-utils – Test utilities for Nuxt
◻ @nuxt/ui – The Intuitive UI Library powered by Reka UI and Tailwind CSS
<presses Ctrl-C or Esc>
■ Would you like to install any of the official modules?

npm error code 1
npm error path /home/arun-mani-j/Projects
npm error command failed
npm error command sh -c create-nuxt foo
npm error A complete log of this run can be found in: /home/arun-mani-j/.cache/npm/_logs/2025-06-21T08_14_44_025Z-debug-0.log

Failing with an error code is not a good user experience in my opinion.

I would suggest we do something like this:

  1. Let user know that they can skip the installation by pressing Esc or Ctrl-C etc.
  2. Handle the rejection gracefully.

I'm happy to make a PR if you think this behavior seems okay or if we can do something better.

Thanks for Nuxt!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions