Uncaught DOMException: Failed to execute 'createElement' on 'Document' when loading from public

See original GitHub issue

I get this error when im trying to load a svg file as component from public/: Uncaught DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('/icons/moon.svg?component') is not a valid name.

image

My structure: image

My env.d.ts:

/// <reference types="vite/client" />
/// <reference types="vite-svg-loader" />

My vite.config.ts:

import { fileURLToPath, URL } from 'url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import svgLoader from 'vite-svg-loader'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), svgLoader()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

Repo: https://github.com/Backifyco/backify-font-logo-finder

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
luucasrbcommented, Jul 20, 2022

Having the same error here in production build.

0reactions
luucasrbcommented, Oct 26, 2022

In my case, I was using reserved JS/TS words for naming the svg’s objects, i.e: import Export from './export.svg?component'. So, I’ve changed it to snake case with suffix: import export_icon from './export.svg?component'

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to execute 'createElement' on 'Document': The tag ...
but I'm getting the following error: InvalidCharacterError: Failed to execute 'createElement' on 'Document': The tag name provided ('/static/ ...
Read more >
Failed to execute 'createElement' on 'Document': The ... - GitHub
I'm trying to have react-svg-loader 2.1.0 to load SVG using webpack, but I'm getting this error: Failed to execute 'createElement' on ...
Read more >
Failed to execute 'createElement' on 'Document' error message
Login to your site from an incognito window · Install and activate the Health Check & Troubleshooting plugin. · Navigate to “Plugins >...
Read more >
Failed to execute 'createElement' on 'Document': The tag ...
I am getting the error: "DOMException: Failed to execute 'createElement' on 'Document': The tag name provided is not a valid name".
Read more >
The tag name provided ('/static/media/index.c6592bb6.ts') is ...
Failed to execute 'createElement' on 'Document': The tag name provided ('./GuessLikeList/GuessLikeList.jsx') is not a valid name. It means can not execute with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found