it returns an error “TypeError [ERR_INVALID_ARG_TYPE]: The “data” argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined” Console.logging buffer returns ‘undefined’. How can I avoid this error and convert svg to png?
I tried your code and it works fine.
Possible issues: 1) SVG file is not in the same directory as the JS code you’re running.
2) You’re on windows and that forward slash in filename is messing up the path. Try to use path.join to create valid path.