Prozessing File:Pereslavl_narrow_gauge_railway_1990.svg with
svgo -i Pereslavl_narrow_gauge_railway_1990.svg -o output.svg --pretty --indent=1
leads to
TypeError: Cannot read property 'toFixed' of undefined
at strongRound (C:\Users\jkalliau\AppData\Roaming\npm\node_modules\svgo\plugins\convertPathData.js:766:21)
at C:\Users\jkalliau\AppData\Roaming\npm\node_modules\svgo\plugins\convertPathData.js:424:17
at Array.filter (<anonymous>)
at filters (C:\Users\jkalliau\AppData\Roaming\npm\node_modules\svgo\plugins\convertPathData.js:272:17)
at Object.exports.fn (C:\Users\jkalliau\AppData\Roaming\npm\node_modules\svgo\plugins\convertPathData.js:79:20)
at C:\Users\jkalliau\AppData\Roaming\npm\node_modules\svgo\lib\svgo\plugins.js:61:45
at Array.filter (<anonymous>)
at monkeys (C:\Users\jkalliau\AppData\Roaming\npm\node_modules\svgo\lib\svgo\plugins.js:48:39)
at C:\Users\jkalliau\AppData\Roaming\npm\node_modules\svgo\lib\svgo\plugins.js:68:17
at Array.filter (<anonymous>)
(Same as in https://github.com/svg/svgo/issues/987, except here I don't specify convertPathData, therfore it is enabled.)
Can confirm this is not an issue in v1.2.2
Yep, looks like this issue is fixed with v1.2.2
Need to keep in mind if upgrading that the issue exists in 1.3.0
Seems like no more an issue.
Seems like no more an issue.
@GreLI no, this issue exists in 1.3.0
The issue is not present in 1.2.2.
Please reopen.
Can you elaborate? I couldn't reproduce.
I tried with 1.3.0 (updated with npm install -g svgo some days ago)
I tried
https://upload.wikimedia.org/wikipedia/commons/f/f2/Pereslavl_narrow_gauge_railway_1990.svg
and I tried
https://github.com/svg/svgo/files/2129417/input.svg.txt
both did not have the reported issue, but a different one the Text 78H-0525 on the top has a problem the H moved to the right, but I that might be a rounding-error. I would consinder this issue as closed.
@justrhysism Maybe you have another example and you might start a new issue?
@JoKalliauer yeah I'll create a new test case and submit a new issue if @GreLI is happy with a new issue for the same error.
Has the issue been fixed?
In July I was not able any more to reproduce this bug with the file above, therefore I consider it as fixed, and would keep it closed.
If the result depends on bondary conditions (like which OS) it is a different problem, and should be reported imho in a new issue.
If the error was reintroduced, it is imho a new bug and therefore a new issue.
If another file produces the same bug, it imho another issue with the same Error-message.
Therfore I consinder my reported ssue as fixed.
If someone has the same error-message, they should in my opinon write a new bug-report (svg-file, version of SVGO, Operating system,...) and should refer to this issue.
I've had this issue recently using svgo v1.3.0. I rolled back to v1.2.2 and it was fixed. postcss-svgo includes svgo v1.3.0 and it won't compile base64 svgs without this error. It doesn't happen on all base64 svgs which makes it hard to troubleshoot.
I am seeing this error in gulp-imagemin with an svg that is of text that has been converted to outlines.
[12:03:47] gulp-notify: [Error running Gulp] TypeError in plugin 'gulp-imagemin'
Message:
Cannot read property 'toFixed' of undefined
Details:
fileName: /Users/adamhite/Sites/am-banners/src/kestra-financial/2019-campaign-awareness/src/emoney-300x250/images/text1.svg
[12:03:47] TypeError: Cannot read property 'toFixed' of undefined
at strongRound (/Users/adamhite/Sites/am-banners/src/kestra-financial/2019-campaign-awareness/node_modules/svgo/plugins/convertPathData.js:766:21)
at /Users/adamhite/Sites/am-banners/src/kestra-financial/2019-campaign-awareness/node_modules/svgo/plugins/convertPathData.js:424:17
at Array.filter ()
at filters (/Users/adamhite/Sites/am-banners/src/kestra-financial/2019-campaign-awareness/node_modules/svgo/plugins/convertPathData.js:272:17)
at Object.exports.fn (/Users/adamhite/Sites/am-banners/src/kestra-financial/2019-campaign-awareness/node_modules/svgo/plugins/convertPathData.js:79:20)
at /Users/adamhite/Sites/am-banners/src/kestra-financial/2019-campaign-awareness/node_modules/svgo/lib/svgo/plugins.js:59:45
at Array.filter ()
at monkeys (/Users/adamhite/Sites/am-banners/src/kestra-financial/2019-campaign-awareness/node_modules/svgo/lib/svgo/plugins.js:46:39)
at /Users/adamhite/Sites/am-banners/src/kestra-financial/2019-campaign-awareness/node_modules/svgo/lib/svgo/plugins.js:66:17
at Array.filter ()
@adam-hite it may be because of incorrect image. But as I see by stacktrace, there is outdated version of SVGO underhood.
Same as @djmtype! Rolling back to v1.2.2 fixed this error for me. Yet to pinpoint the root cause.
Older version fixed it, we are rolling back to v1.2.2
Edit: The issue occurred with SVGs that contain <path d attribute values that use shorthand for decimals, omitting the zero integer.
When in your package.json a svgo release is used where this issue should have been fixed,
but you still get this error, your project quite probably uses another package that indirectly uses an older/outdated svgo dependency. You can find this out by using the npm ls command (not sure whether yarn supports this, too, I switched from yarn back to npm when npm became fast enough). This will list a dependency tree of the packages in the project. For making this easier, you could just pipe the output into a text file, then search in that text file for svgo packages and trace the tree line back to which package is requiring it. In my case (roots.io Sage 9 base theme), the package css-loader required other old dependencies and one of them requires a very old package of svgo (css-loader is used for inlining SVGs in the CSS). Luckily there was already a newer version of css-loader available that requires newer dependency which themselves, in turn, require a recent svgo with this issue fixed.
So I've experienced this with babel-plugin-inline-react-svg today, but they won't update their version of svgo because this library was updated to be asynchronous. Here's an issue about that: https://github.com/svg/svgo/issues/1015
Is this essentially a catch-22 where neither library will make a move in either direction?
It was an easy fix for me to re-optimise my SVG to not strip the zero integer, but it may not always be that way...
Example of svg that triggers this error:
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
<path d="M40.142 33.91L29.82 23.59a14.698 14.698 0 00.07-13.6 14.75 14.75 0 10-5.902 19.595l10.224 10.224 5.93-5.897zm-23.387-7.562a9.633 9.633 0 119.65-9.552 9.616 9.616 0 01-9.65 9.552z"/>
</svg>
Have you tried to update to a recent version of svgo, also as a sub-dependency? https://github.com/svg/svgo/issues/990#issuecomment-570012473
This issue just popped up in my notifications. Has anyone edited or added something I hadn't noticed?
Most helpful comment
So I've experienced this with babel-plugin-inline-react-svg today, but they won't update their version of svgo because this library was updated to be asynchronous. Here's an issue about that: https://github.com/svg/svgo/issues/1015
Is this essentially a catch-22 where neither library will make a move in either direction?
It was an easy fix for me to re-optimise my SVG to not strip the zero integer, but it may not always be that way...