docus icon indicating copy to clipboard operation
docus copied to clipboard

Issue with npx nuxt generate Command When Using ssr: false Configuration in nuxt.config.js

Open frs99 opened this issue 1 year ago • 2 comments

Problem Description:

I am using Nuxt.js to develop a web application and I'm encountering an issue when trying to generate the project using the command npx nuxt generate with the ssr configuration in the nuxt.config.js file set to false. This issue does not occur when the ssr value is set to true. I hope you can assist me in understanding the cause and finding a solution to this problem.

Steps Taken:

  1. I modify the Nuxt configuration file (nuxt.config.ts) to look like the following:

    // nuxt.config.ts
    
    export default defineNuxtConfig({
       app: {
         buildAssetsDir: 'nuxt',
       },
       ssr: false,
       // https://github.com/nuxt-themes/docus
       extends: '@nuxt-themes/docus',
    
       modules: [
         // https://github.com/nuxt-modules/plausible
         '@nuxtjs/plausible',
         // https://github.com/nuxt/devtools
         '@nuxt/devtools'
       ]
     })
    
    
  2. Then I execute the following command to generate the project:

    npx nuxt generate
    

Issue:

When executing the command npx nuxt generate with ssr: false, an error occurs during the generation process, and the following message appears:

ERROR [nuxt] [request error] [unhandled] [500] Unexpected token '<', "<!DOCTYPE "... is not valid JSON
  at JSON.parse (<anonymous>)
  at parseJSONFromBytes (node:internal/deps/undici/undici:6662:19)
  at successSteps (node:internal/deps/undici/undici:6636:27)
  at node:internal/deps/undici/undici:1236:60
  at node:internal/process/task_queues:140:7
  at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
  at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)

 ├─ /__studio.json (1217ms) (Error: [500] )
 ├─ / (1217ms)
 ├─ /index.html (1213ms)
 ├─ /404.html (1213ms)
 ├─ /200.html (1213ms)
 ├─ /api/search (2323ms)
 ├─ /api/_content/cache.1692048783655.json (2378ms)
Errors prerendering:
  ├─ /__studio.json (500)
 ERROR  Exiting due to prerender errors.

Actions Taken:

  1. I have read the Nuxt documentation regarding project generation and understanding how to set ssr to false.
  2. I tried executing the npx nuxt generate command with ssr: true, and no errors occurred.

Expected Outcome:

I expect there to be a way to generate the project using ssr: false without encountering the aforementioned errors. I kindly request guidance towards a suitable solution for this issue.

frs99 avatar Aug 14 '23 21:08 frs99

I have the same problem, were you able to solve it?

BrunoGGM avatar Oct 09 '23 22:10 BrunoGGM

I have the same problem, were you able to solve it?

no bro

frs99 avatar Oct 10 '23 19:10 frs99