rive-lottie icon indicating copy to clipboard operation
rive-lottie copied to clipboard

rive-lottie Converter - TypeError in handleScaleX

Open ClaudiusMa opened this issue 6 months ago • 0 comments

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 () at .../rive-lottie/src/converter/animations/animations.js:161:30 at Array.forEach () at convertAnimations (.../rive-lottie/src/converter/animations/animations.js:159:19) at module.exports (.../rive-lottie/src/converter/index.js:66:26) at main (.../rive-lottie/src/index.js:31:26) at Object. (.../rive-lottie/run_convert.js:9:26) at Module._compile (node:internal/modules/cjs/loader:1376:14)

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); } }

ClaudiusMa avatar Jun 03 '25 07:06 ClaudiusMa