Failed to execute 'createElement' on 'Document': The tag name provided ('static/media/arrow-right.981294d1.svg') is not a valid name.

See original GitHub issue

I have error in storybook when config svgr webpack for project.

This is my config

const path = require('path');

module.exports = async ({ config }) => {
  config.module.rules.push(
    {
      test: /\.less$/,
      use: [
        'style-loader',
        'css-loader',
        {
          loader: 'less-loader',
          options: {
            javascriptEnabled: true,
          },
        },
      ],
      include: path.resolve(__dirname, '../'),
    },
    {
      test: /\.svg$/,
      use: [
        {
          loader: '@svgr/webpack',
          options: {
            icon: true,
          },
        },
      ],
    }
  );
  config.resolve.extensions.push('.js', '.jsx', '.svg');
  config.resolve.modules.push(path.resolve('.'));
  return config;
};

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

68reactions
GR34SEcommented, May 29, 2020

Hi @tranthaison1231 , do you have the solution for the error?

This solution worked for me: https://stackoverflow.com/a/61706308/10331102

add the following to yours storybook’s webpackFinal config:

        const fileLoaderRule = config.module.rules.find(
            (rule) => rule.test && rule.test.test(".svg")
        );
        fileLoaderRule.exclude = /\.svg$/;

        config.module.rules.push({
            test: /\.svg$/,
            enforce: "pre",
            loader: require.resolve("@svgr/webpack")
        });
1reaction
andyfordcommented, Oct 21, 2020

Just ran into this with a Preact project.

solution was the same as was posted by @GR34SE but with a different loader

{
  test: /\.svg$/,
  enforce: 'pre',
  use: ['preact-svg-loader'],
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to execute 'createElement' on 'Document': The tag ...
ts') is not a valid name. What does this error even mean? It looks like it doesn't like the typescript extension. Any ideas...
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 >
Failed to execute 'createElement' on 'Document' error message
Failed to execute 'createElement' on 'Document': The tag name provided ('core/location') is not a valid name. in core/location in div in withData(a) in...
Read more >
Error: Failed to execute "createElement" on "Document"
Error : Failed to execute "createElement" on "Document": The tag name provided is not a valid name. January 18, 2022 ...
Read more >
Failed To Execute 'Createelement' On 'Document': The Tag ...
Failed to execute 'createElement' on 'Document': The tag name provided is not a valid name #197. I'm trying to have reactsvgloader 2.1.0 to...
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