nuxt/cli

The nuxi preview command does not work with the custom nitro.output setting

Closed this issue · 3 comments

Environment

  • Operating System: Darwin
  • Node Version: v20.13.0
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: npm@10.5.2
  • Builder: -
  • User Config: devtools, nitro
  • Runtime Modules: -
  • Build Modules: -

Reproduction

  1. git clone git@github.com:alSergey/nuxi-start-repro.git
  2. Run command npm run build_and_start

Describe the bug

The nuxi preview command doesn't run because it expects an .output folder. As I understand it, the problem is in this lines

const defaultOutput = resolve(cwd, '.output', 'nitro.json') // for backwards compatibility
const nitroJSONPaths = [resolvedOutputDir, defaultOutput]
const nitroJSONPath = nitroJSONPaths.find((p) => existsSync(p))
if (!nitroJSONPath) {
consola.error(
'Cannot find `nitro.json`. Did you run `nuxi build` first? Search path:\n',
nitroJSONPaths,
)
process.exit(1)
}

Additional context

No response

Logs

> nuxt preview

 ERROR  Cannot find nitro.json. Did you run nuxi build first? Search path:                                                                                                                                  20:12:34
 [ '/Users/seralekhin/Desktop/nuxi-start-repro/server/dist/nitro.json',
  '/Users/seralekhin/Desktop/nuxi-start-repro/.output/nitro.json' ]

Hello, could you please tell me the status of this issue?

Have the same problem. Looks like the .output dir is hardcoded. Can't use preview|start command with custom output dir name now :(
Do you have plans for fix this?

pi0 commented

Hi. The issue should be solved via nightly release channel. (#376)