Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Failed to load transformer on Windows #3114

Open
Skyost opened this issue Feb 10, 2025 · 1 comment
Open

Error: Failed to load transformer on Windows #3114

Skyost opened this issue Feb 10, 2025 · 1 comment

Comments

@Skyost
Copy link

Skyost commented Feb 10, 2025

Environment

Version

v3

Reproduction

Try the sample code here : https://content.nuxt.com/docs/getting-started/configuration#transformers, on Windows.

Description

Got the following error :

[@nuxt/content 11:35:34]  ERROR  Failed to load transformer ~/transformers/title-suffix Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'

    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:205:11)
    at defaultLoad (node:internal/modules/esm/load:103:3)
    at ModuleLoader.load (node:internal/modules/esm/loader:708:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:488:43)
    at #createModuleJob (node:internal/modules/esm/loader:512:36)
    at #getJobFromResolveResult (node:internal/modules/esm/loader:281:34)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:249:41)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:551:25)

with the sample code.

nuxt.config.ts
export default defineNuxtConfig({
  content: {
    build: {
      transformers: [
        '~/transformers/title-suffix',
      ],
    },
  },
})
~/transformers/title-suffix.ts
import { defineTransformer } from '@nuxt/content'

export default defineTransformer({
  name: 'title-suffix',
  extensions: ['.md'],
  transform(file) {
    return {
      ...file,
      title: file.title + ' (suffix)',
    }
  },
})
@Skyost
Copy link
Author

Skyost commented Feb 13, 2025

Note that it works with a .js file instead of a .ts file.

Skyost added a commit to Skyost/MesCoursDeMaths that referenced this issue Feb 21, 2025
Inutilisable à cause du bug suivant : nuxt/content#3114.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant