Node.js 在使用npm run build运行reactjs项目时,获取错误--postsss svgo:error解析SVG:Attribute而不带值
代码在npm启动时运行良好。但在运行npm运行构建时,显示以下错误:Node.js 在使用npm run build运行reactjs项目时,获取错误--postsss svgo:error解析SVG:Attribute而不带值,node.js,reactjs,npm,npm-run,Node.js,Reactjs,Npm,Npm Run,代码在npm启动时运行良好。但在运行npm运行构建时,显示以下错误: react-scripts build Creating an optimized production build... Failed to compile. postcss-svgo: Error in parsing SVG: Attribute without value Line: 0 Column: 60 Char: d npm ERR! code ELIFECYCLE npm ERR! errno 1 npm E
react-scripts build
Creating an optimized production build...
Failed to compile.
postcss-svgo: Error in parsing SVG: Attribute without value
Line: 0
Column: 60
Char: d
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! matchtimings@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the matchtimings@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
错误的屏幕截图:
当我们在代码中的某个地方使用编码格式的svg数据URI时,可能会出现这种错误,例如background image:url('data:image/svg xml…) 因此,只需使用任何URL编码器/解码器online()解码编码的svg URI内容,并在那里替换解码的svg内容 例如: 编码的URI
background-image: url('data:image/svg+xml,%3csvg xmlns=http://www.w3.org/2000/svg width=12 height=12 fill=none stroke=%23dc3545 viewBox=0 0 12 12%3e%3ccircle cx=6....');
background-image: url('data:image/svg xml,<svg xmlns=http://www.w3.org/2000/svg width=12 height=12 fill=none stroke=#dc3545 viewBox=0 0 12 12>......</svg>');
解码的URI
background-image: url('data:image/svg+xml,%3csvg xmlns=http://www.w3.org/2000/svg width=12 height=12 fill=none stroke=%23dc3545 viewBox=0 0 12 12%3e%3ccircle cx=6....');
background-image: url('data:image/svg xml,<svg xmlns=http://www.w3.org/2000/svg width=12 height=12 fill=none stroke=#dc3545 viewBox=0 0 12 12>......</svg>');
backgroundimage:url('data:image/svgxml,…');