Uncaught DOMException: Failed to execute 'createElement' on 'Document' when loading from public
See original GitHub issueI 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.
My structure:
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))
}
}
})
Issue Analytics
- State:
- Created a year ago
- Comments:10 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Having the same error here in production build.
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'