nuxt-seo icon indicating copy to clipboard operation
nuxt-seo copied to clipboard

with @nuxtjs/seo when deploying to Cloudflare ("stdin" is not exported)

Open acdxxx177 opened this issue 10 months ago • 1 comments

Describe the bug

I am currently using the @nuxtjs/seo module in my Nuxt 3 project for SEO optimization. However, I encountered an issue when deploying my application to Cloudflare.

The error message is as follows:

✔ Server built in 3171ms 16:55:56 ℹ Initializing prerenderer nitro 16:55:57 ℹ Prerendering 1 routes nitro 16:56:07 ├─ /api/_content/cache.1712220946370.json (76ms) nitro 16:56:07 ℹ Prerendered 1 routes in 10.104 seconds nitro 16:56:07 ✔ Generated public dist nitro 16:56:07 ℹ Building Nuxt Nitro server (preset: cloudflare-pages) nitro 16:56:07

[nitro 16:56:16] ERROR RollupError: "stdin" is not exported by "node_modules/.pnpm/[email protected]/node_modules/unenv/runtime/node/process/index.mjs", imported by ".nuxt/dist/server/_nuxt/prompt-W7GJNXZP.js".

1: import { stdin, stdout } from "node:process"; ^ 2: import f from "node:readline"; 3: import { WriteStream } from "node:tty";

[16:56:16] ERROR "stdin" is not exported by "node_modules/.pnpm/[email protected]/node_modules/unenv/runtime/node/process/index.mjs", imported by ".nuxt/dist/server/_nuxt/prompt-W7GJNXZP.js".

This error occurs when I set the NITRO_PRESET environment variable to cloudflare-pages and run nuxt build.

Here is the relevant part of my nuxt.config.ts:

export default defineNuxtConfig({
  modules: ["@nuxtjs/seo", "@nuxtjs/i18n", "@nuxt/content"],
  i18n: {
    vueI18n: "./i18n.config.ts",
    locales: [
      { code: "en", iso: "en-US" },
    ],
    defaultLocale: "en",
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: "i18n_redirected",
      redirectOn: "root",
    },
  },
  site: {
    url: "http://www.xxxxx.xxx",
    name: "xxxxxxxxxxx",
    description: "xxxxxxxxxx",
  },
  content: {},
  devtools: { enabled: true },
  nitro: {
    preset: 'cloudflare-pages',
    prerender: {
      autoSubfolderIndex: false
    }
  },
});

I encounter this error both on the Cloudflare website and locally. If I remove '@nuxtjs/seo' or the 'preset: cloudflare-pages' configuration, the build proceeds without any issues.

Reproduction

No response

System / Nuxt Info

------------------------------
- Operating System: Windows_NT
- Node Version:     v20.11.1
- Nuxt Version:     3.10.3
- CLI Version:      3.10.1
- Nitro Version:    2.9.3
- Package Manager:  [email protected]
- Builder:          -
- User Config:      modules, i18n, site, content, devtools, nitro
- Runtime Modules:  @nuxtjs/[email protected], @nuxtjs/[email protected], @nuxt/[email protected]
- Build Modules:    -
------------------------------

acdxxx177 avatar Apr 04 '24 09:04 acdxxx177