@@ -11,7 +11,7 @@ import {
11
11
} from '@nuxt/kit'
12
12
import { readPackageJSON } from 'pkg-types'
13
13
import { lt , gte } from 'semver'
14
- import { join } from 'pathe'
14
+ import { dirname , join } from 'pathe'
15
15
import type { FetchOptions } from 'ofetch'
16
16
import { setupDevToolsUI } from './devtools'
17
17
import { NuxtScriptBundleTransformer } from './plugins/transform'
@@ -119,7 +119,10 @@ export default defineNuxtModule<ModuleOptions>({
119
119
return
120
120
}
121
121
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 )
123
126
// couldn't be found for some reason, assume compatibility
124
127
if ( unheadPath ) {
125
128
const { version : unheadVersion } = await readPackageJSON ( join ( unheadPath , 'package.json' ) )
@@ -129,7 +132,7 @@ export default defineNuxtModule<ModuleOptions>({
129
132
else if ( lt ( unheadVersion , '1.11.5' ) ) {
130
133
logger . warn ( `Nuxt Scripts recommends Unhead >= 1.11.5, you are using v${ unheadVersion } . Please run \`nuxi upgrade --clean\` to upgrade...` )
131
134
}
132
- else if ( gte ( unheadVersion , '^2 ' ) ) {
135
+ else if ( gte ( unheadVersion , '2.0.0-beta.1 ' ) ) {
133
136
isUnheadV2 = true
134
137
}
135
138
}
0 commit comments