Developer Questions

Ask a Question
Back to All

Uncaught Error: Cannot find module 'crypto-js' at n (xumm-sdk.min.js:1:155)

The module 'crypto-js' is installed in node_modules but no matter what I've tried for about a month and a half now trying to generate xrpl.org escrow condition and fulfillment always references xumm-sdk throwing Uncaught Error: Cannot find module 'crypto-js' at n (xumm-sdk.min.js:1:155) when running:

            const cc = require('crypto-js');
            const crypto = require('crypto');

            const preimageData = crypto.randomBytes(32);
            const fulfillment = new cc.PreimageSha256();
            fulfillment.setPreimage(preimageData);

            const condition = fulfillment.getConditionBinary().toString('hex').toUpperCase();
            console.log('Condition:', condition);

            // Keep secret until you want to finish the escrow
            const fulfillment_hex = fulfillment.serializeBinary().toString('hex').toUpperCase();
            console.log('Fulfillment:', fulfillment_hex);