nuxt-modules / sitemap

Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.
https://nuxtseo.com/sitemap
335 stars 30 forks source link

fix: Issue in detecting the version for @nuxtjs/robots pakcage #379

Closed cyrilf closed 1 week ago

cyrilf commented 1 week ago

🐛 The bug

When I build my Nuxt project the following error occurs:

[@nuxtjs/sitemap 9:35:41 AM] WARN You are using @nuxtjs/robots vfalse. For the best compatibility, please upgrade to @nuxtjs/robots v4.0.0 or higher.

resulting further down in the build to: Duplicated imports "getPathRobotConfig", the one from "/home/x/dev-project/node_modules/@nuxtjs/sitemap/dist/runtime/nitro/composables/getPathRobotConfigPolyfill" has been ignored and "/home/x/dev-project/node_modules/@nuxtjs/robots/dist/runtime/nitro/composables/getPathRobotConfig.js" is used

Reproduction

Use the reproduction link below and watch the console. The warning messages are incorrectly displayed but by selecting the text in the console, you can read them entirely.

OR

Create a new Nuxt project: npx nuxi@latest init test-seo

Then go in this project cd test-seo

Then install nuxt-seo npx nuxi module add @nuxtjs/seo

Then run a build: npm run build

You will see the error messages mentioned earlier.

Context

The error seems to occur in that hook which is calling this function

Maybe related to this older issue

🛠ī¸ To reproduce

https://stackblitz.com/edit/nuxt-starter-vtmy8d?file=package.json

🌈 Expected behavior

The sitemap module should correctly find my nuxtjs/robots version and I see no error or warning in the console.

ℹī¸ Additional context

These are the dependencies:

"dependencies": {
    "@nuxtjs/seo": "^2.0.0-rc.23",
    "nuxt": "^3.14.0",
    "vue": "latest",
    "vue-router": "latest"
  }

I'm using npm version: 10.2.4 and node version v20.11.0


Maybe fixed by https://github.com/nuxt/nuxt/pull/29793 ? 🤔

harlan-zw commented 1 week ago

Thanks for raising this, it seems like an upstream bug in Nuxt. I've set up a graceful fallback if the version read fails.

cyrilf commented 1 week ago

Nice, thanks for the quick answer and fix! 👍 Do you think I need to raise an issue on the Nuxt repo or is this one solving it already?

harlan-zw commented 1 week ago

Yes that should do the trick!