Skip to content

Dev server doesn't work with nitro: false and vite: true options #844

@deleteme

Description

@deleteme

Environment

  • Operating System: Darwin
  • Node Version: v18.15.0
  • Nuxt Version: 2.17.0
  • Nitro Version: 2.5.2
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: head, css, plugins, components, buildModules, modules, axios, build, bridge, serverHandlers, devServerHandlers, devServer, typescript, nitro
  • Runtime Modules: @nuxtjs/axios@5.13.6
  • Build Modules: (), @nuxt/bridge@3.0.0-28132497.798694a

Reproduction

https://github.com/deleteme/nuxt2-bridge-vite-bug/tree/vite-with-legacy-server

Describe the bug

After changing two bridge options in nuxt.config.js (vite: true, nitro: false), the nuxt dev command fails with an error.

Additional context

This reproduction git repository contains a fresh Nuxt 2 project via (yarn create nuxt-app), with Nuxt Bridge being the only additional package.

This bug was encountered while evaluating Nuxt Bridge. I wanted to know if Nuxt Bridge works (or what parts of it work) in a brand new Nuxt 2 app to determine if it's suitable for use in the migration of a large Nuxt 2 app to Nuxt 3.

Logs

I  ~/s/nuxt2-bridge-vite-bug vite-with-legacy-server 20.1s | 130 ❱ yarn dev
yarn run v1.22.19
$ nuxt dev
ℹ Module nuxt-bridge took 4.35ms to setup.
ℹ Module imports took 0.89ms to setup.
🧪  Vite mode is experimental and some nuxt modules might be incompatible
    If you find a bug, please report via https://github.com/nuxt/bridge/issues with a minimal reproduction.
ℹ Module nuxt-bridge:vite took 0.54ms to setup.

   ╭───────────────────────────────────────╮
   │                                       │
   │   Nuxt @ v2.17.0                      │
   │                                       │
   │   ▸ Environment: development          │
   │   ▸ Rendering:   server-side          │
   │   ▸ Target:      server               │
   │                                       │
   │   Listening: http://localhost:3000/   │
   │                                       │
   │   ⚡  Vite Mode Enabled (v3.0.0)      │
   │                                       │
   ╰───────────────────────────────────────╯

ℹ Preparing project for development
ℹ Initial build may take a while
ℹ Discovered Components: .nuxt/components/readme.md
✔ Builder initialized
✔ Nuxt files generated

 ERROR  Cannot read properties of undefined (reading 'replace')

  at buildClient (node_modules/@nuxt/bridge/dist/chunks/vite.mjs:317:71)
  at bundle (node_modules/@nuxt/bridge/dist/chunks/vite.mjs:739:9)
  at async Builder.build (node_modules/@nuxt/builder/dist/builder.js:249:5)
  at async Object._buildDev (node_modules/@nuxt/cli/dist/cli-dev.js:79:5)
  at async Object.startDev (node_modules/@nuxt/cli/dist/cli-dev.js:55:7)
  at async Object.run (node_modules/@nuxt/cli/dist/cli-dev.js:44:5)
  at async NuxtCommand.run (node_modules/@nuxt/cli/dist/cli-index.js:356:7)

Trying to load localhost:3000 eventually times out with an error page:

Error
Renderer resources are not loaded! Please check possible console errors and ensure dist (/Users/deleteme/src/nuxt2-bridge-vite-bug/.nuxt/dist/server) exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions