NuxtN
Nuxt4mo ago
8 replies
Yuri

Missing "./runtime" specifier in "@nuxt/image" package

Hello. I want to create a custom provider for @nuxt/image. I use instructions from https://image.nuxt.com/advanced/custom-provider

My custom provider is:
import { joinURL } from 'ufo'
import { createOperationsGenerator, defineProvider } from '@nuxt/image/runtime'

const operationsGenerator = createOperationsGenerator()

export default defineProvider<{ baseURL?: string }>({
  getImage (src, { modifiers, baseURL }) {
    if (!baseURL) {
      // also support runtime config
      baseURL = useRuntimeConfig().public.siteUrl
    }

    const operations = operationsGenerator(modifiers)

    return {
      url: joinURL(baseURL, src + (operations ? '?' + operations : ''))
    }
  }
})


But I get the error: " Missing "./runtime" specifier in "@nuxt/image" package".

What do I do incorrect?
Nuxt Image
If a CDN provider is not supported, you can define it yourself.
Custom Provider
Was this page helpful?