@@ -11,7 +11,7 @@ import {
1111} from '@nuxt/kit'
1212import { readPackageJSON } from 'pkg-types'
1313import { lt , gte } from 'semver'
14- import { join } from 'pathe'
14+ import { dirname , join } from 'pathe'
1515import type { FetchOptions } from 'ofetch'
1616import { setupDevToolsUI } from './devtools'
1717import { NuxtScriptBundleTransformer } from './plugins/transform'
@@ -119,7 +119,10 @@ export default defineNuxtModule<ModuleOptions>({
119119 return
120120 }
121121 let isUnheadV2 = false
122- const unheadPath = await resolvePath ( '@unhead/vue' ) . catch ( ( ) => undefined )
122+ const unheadPath = await resolvePath ( '@unhead/vue' )
123+ . catch ( ( ) => undefined )
124+ // compatibility
125+ . then ( p => p ?. endsWith ( 'index.mjs' ) ? dirname ( p ) : p )
123126 // couldn't be found for some reason, assume compatibility
124127 if ( unheadPath ) {
125128 const { version : unheadVersion } = await readPackageJSON ( join ( unheadPath , 'package.json' ) )
@@ -129,7 +132,7 @@ export default defineNuxtModule<ModuleOptions>({
129132 else if ( lt ( unheadVersion , '1.11.5' ) ) {
130133 logger . warn ( `Nuxt Scripts recommends Unhead >= 1.11.5, you are using v${ unheadVersion } . Please run \`nuxi upgrade --clean\` to upgrade...` )
131134 }
132- else if ( gte ( unheadVersion , '^2 ' ) ) {
135+ else if ( gte ( unheadVersion , '2.0.0-beta.1 ' ) ) {
133136 isUnheadV2 = true
134137 }
135138 }
0 commit comments