-
Notifications
You must be signed in to change notification settings - Fork 107
Description
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.logFailing with an error code is not a good user experience in my opinion.
I would suggest we do something like this:
- Let user know that they can skip the installation by pressing
EscorCtrl-Cetc. - 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!