rive-lottie Converter - TypeError in handleScaleX
Error
TypeError: Cannot destructure property 'transform' of 'lottieObject' as it is null.
at handleScaleX (.../rive-lottie/src/converter/animations/animations.js:47:13)
at .../rive-lottie/src/converter/animations/animations.js:170:21
at Array.forEach (
My code: const fs = require('fs'); const converter = require('./src/index');
const rivFilePath = './riveAnimation.riv'; // Ensure this file exists
try { const buffer = fs.readFileSync(rivFilePath); const animationsData = converter(buffer);
if (animationsData && animationsData.length > 0) {
animationsData.forEach((anim, index) => {
const outputFilePath = `./data_rive_${index}.json`;
fs.writeFile(
outputFilePath,
JSON.stringify(anim, null, 2),
(err) => {
if (err) {
console.error(`Error writing file ${outputFilePath}:`, err);
return;
}
console.log(`Successfully wrote ${outputFilePath}`);
},
);
});
} else {
console.log("No animations data found or converter returned empty/null.");
}
} catch (error) {
if (error.code === 'ENOENT') {
console.error(Error: The Rive file was not found at ${rivFilePath}. Please ensure the file exists at this location.);
} else {
console.error("An error occurred:", error);
}
}