cli icon indicating copy to clipboard operation
cli copied to clipboard

`add` command creates `nuxt.config.ts` while `nuxt.config.js` exists

Open meirroth opened this issue 1 year ago • 2 comments

Not sure if this expected, when running the add command (for example npx nuxi@latest module add nuxt-viewport) in a project using nuxt.config.js a new file is created nuxt.config.ts with the new module:

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  modules: ["nuxt-viewport"]
})

I would expect it to add the new module to the exisiting config file.

Reproduce this issue on StackBlitz starter: https://stackblitz.com/fork/github/nuxt/starter/tree/v3-stackblitz

Apologies if this is an upstream issue.

meirroth avatar Apr 28 '24 14:04 meirroth

The issue is here: https://github.com/nuxt/cli/blob/89731870dac34a443febf5974f0515596b17914b/src/commands/module/add.ts#L119.

We should support iterating over a list of possible files and picking the first.

danielroe avatar Apr 29 '24 08:04 danielroe

@danielroe I created a PR

meirroth avatar Apr 29 '24 20:04 meirroth