N
Nuxt3d ago
freb97

Module Nuxt v4 compatibility specification

Hey everyone, i saw that a lot of modules now use '>=3.0.0' to indicate compatibility with v3 and v4:
meta: {
compatibility: {
nuxt: '>=3.0.0',
},
},
meta: {
compatibility: {
nuxt: '>=3.0.0',
},
},
Is this really the correct way to do this? Because i got a complaint again today from a user saying the module is not compatible: "The module @konkonam/nuxt-shopify is not compatible with Nuxt 4.0.3 (requires ^3.0.0)"
2 Replies
kapa.ai
kapa.ai3d ago
Hi @freb97. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The correct way to specify Nuxt v3 and v4 compatibility in your module's meta.compatibility is to use a semver range that explicitly includes both major versions. Using '>=3.0.0' is not sufficient, because Nuxt 4 does not satisfy the semver constraint ^3.0.0—the caret (^) only matches 3.x.x, not 4.x.x. To support both Nuxt 3 and Nuxt 4, you should use a semver range like:
meta: {
compatibility: {
nuxt: '>=3.0.0 <5.0.0',
},
},
meta: {
compatibility: {
nuxt: '>=3.0.0 <5.0.0',
},
},
This will ensure your module is considered compatible with any Nuxt version from 3.0.0 up to, but not including, 5.0.0. This approach is also reflected in the Nuxt documentation, which recommends specifying the supported Nuxt versions in semver format in the compatibility.nuxt field of your module meta. If the constraint is not met, Nuxt will warn users about incompatibility issues Module Anatomy & Compatibility. If you use ^3.0.0, it will only match 3.x.x, not 4.x.x, which is why users see the error you mentioned. Always use a range that covers all intended major versions. References: - Module Anatomy & Compatibility - defineNuxtModule Examples ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@552257564667019275> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?