无法解决Cannot find module 'crypto-js'和CryptoJS is not defined?

新手上路,请多包涵

我使用npm在cmd中安装了crypto-js,但是在执行js文件时先出现ReferenceError: CryptoJS is not defined,我在网上查到是少了const CryptoJS = require("crypto-js");我加上后又出现Error: Cannot find module 'crypto-js'错误,请问怎么解决?

_0x175e = [
    "jsjiami.com.v6",
    "JMOsw6omwoDCmw==",
    "wp3DkSx5Eg==",
    "HB7CscOJfS3DuUjDv2bDjsOmwr3Cm8KcwoI=",
    "fR/Dqg==",
    "ShRGTcKa",
    "w5Y8VBs=",
    "esKYKQ==",
    "FgIdwrPDnMKOw7k=",
    "HhXCmA==",
    "woNrRsKSwpnDvcKfw4g=",
    "ezBn",
    "w43DkcK5w4MaJiE=",
    "w44Ob8KjwrjCrMKtUA==",
    "HwtswqI=",
    "YsKnwrRawro=",
    "Sm/CpQXCjz4RH8ORSXw=",
    "IsO6w64=",
    "T8OeAQ==",
    "VcK4Hg==",
    "csOmfBJ4",
    "d8OAcA5L",
    "Tn4RL2s=",
    "w7goGizCmw==",
    "w6XDlcOGwpoY",
    "TsK7wpNPwrg=",
    "w7J1CzLCnsO+HA==",
    "w4XDkcK0w5YXPg==",
    "S8KoCcKS",
    "PcKWHcK/Eg==",
    "Z2oMJ3rCiw==",
    "YsKMG8KMwo0=",
    "QsOecgRIwp4=",
    "dFzDkUUxw48Qw7nCmX3CicODCMKnw74IOg==",
    "acO2KU1B",
    "wrAnw6DDrg==",
    "w5MsScKwwoA=",
    "wohZG8KhBg==",
    "b8OieSpZ",
    "w4ZmEsORw6I=",
    "w7jDhxvCh8KY",
    "w7wQa8KFwr0=",
    "IMObw4E3wqU=",
    "JsOjw5Erwrg=",
    "w6MwcsKOwqU=",
    "b8KIwqF0wrs=",
    "XhXDvT52",
    "wrDCmirChSE=",
    "w5t1wpvDuwE=",
    "XA7CtsKeEA==",
    "wonCvVthw78=",
    "U8KPP8KMwq4=",
    "wp7DhCxjGTU=",
    "woPDoBdiEQ==",
    "HjzCrE/Dvg==",
    "SsOQOWHCgg==",
    "w6NdwoXCkMOx",
    "w6shYWQ/",
    "eE/Cgg==",
    "XW/Csj7CmDoA",
    "w680OynCgcK5BA8=",
    "w4PDoMOTwrog",
    "w5R7wqbCpMOPwrMxUcOiM8OuMVLCisKKFsOXAcOWY8O6w5hM",
    "WwjDoht0",
    "PzXCiHHDiA==",
    "QMOFaMKcfQ==",
    "bz9bVsK+",
    "w7Npwp/DsB9ONw==",
    "EcOPBQ3Cig==",
    "woHDnzk=",
    "DsKQLxtd",
    "R8OCJmk=",
    "wp55O8On",
    "bkXCmhTCqg==",
    "w7vDgx3Cg8KU",
    "w6nDo8KdAn8=",
    "O8KwP8KEDw==",
    "wqzCtCHCtCg=",
    "w5nDgmYhw5c=",
    "wp0OZsK+w4A=",
    "wrFxe8KFwp/DvcKew4EbN8K7BMORMx3DuxtOVELChsOEIQ==",
    "BMKWRDc=",
    "IS5dw6nDhQ==",
    "w6geeG8t",
    "SsK/wohywpc=",
    "LBlnw7jDkA==",
    "wodiLsOg",
    "Ig5Ow7/Dlw==",
    "TMOOewRZwoQ=",
    "LjnClV7DvA==",
    "woZsO8KcPQ==",
    "eWvClMKeKQ==",
    "wq1KWsKswr8=",
    "w4p+AGFa",
    "C8O7F8K2CQcKFxxgwo5sfh3DpAFV",
    "w6XDqMKoCw==",
    "w6Z8wqnCpMOe",
    "w6x/CHRhXhV/w7I=",
    "wrvClndGw5Y=",
    "VsKcwo5RwoA=",
    "ZcK2BMKmLQ==",
    "BCcPwofDvQ==",
    "eGEsF20=",
    "eMOcUglq",
    "w4U9XEAMw4/Dm3rCuzpxTg/DvyDDvMONH8OTwpTCtsKbw6k=",
    "VwXDkTxG",
    "CzHCrl3DkQ==",
    "w7PDkVovw4o=",
    "dsONYDdj",
    "w79pwr3Duh4=",
    "w55kwoLCpMOR",
    "w6gbc8KGwpw=",
    "bCnCtMKCCg==",
    "Php5w64=",
    "w7x8wpfDtiQ=",
    "w4TDk2AB",
    "w7lowoHDtgQ=",
    "DB/CsnjDuQ==",
    "woTDl8K3wp4S",
    "wr0Ewq7Dq8Oh",
    "GmHCpGxN",
    "w5/Dm2XDpw==",
    "w5bDpsOCwqoA",
    "YMKowphwwqc=",
    "ahFuVsK9",
    "w57DtEsbw7k=",
    "w6LDo8Kq",
    "UsKzE8KO",
    "w6xlBFl9",
    "WMOgIXbCiw==",
    "DBhjw5fDhQ==",
    "w6pUwoHCnsOs",
    "ZF7CtsKiHg==",
    "wos4w7wCwr0c",
    "JlXCjlpyw5pMw6s=",
    "TcO1N8K4wqE=",
    "SMOzTcKYRw==",
    "w4HDosOzwrUc",
    "wqxdwqE2wrY=",
    "A8OPGQjChw==",
    "wpkxasOxBQ==",
    "wpIZSA==",
    "VsOnEEvChg==",
    "bMOSZy93",
    "c8OwZsKnRQ==",
    "SsK/wpBHwoQ=",
    "ccOsHVFf",
    "w6ZKYMO8w6rDr8OrCHxdwqtdwrDDksOMccKZwobDpQPDgsOrAMKXF8OMPcOySsKuL8KLwq8vwr/DkjbDqsOCbRrCkcOTTFfDlsKkw7PChCM1wqTDisKawpHDt8KCQRY3w6DDgMKVw6M=",
    "w7hYwq3ClsOa",
    "Fic5wqLDiw==",
    "KcKqHCVV",
    "wqvDucKSwrs/",
    "YcOfQcKPSQ==",
    "wpjClmNRw7U=",
    "wpHClSnCizg=",
    "w4PDh8Kw",
    "JsOYGwnCpw==",
    "w5vDksK8w6sl",
    "U8ORCHt+Rw==",
    "woVxO8OSJQ==",
    "b37Chw/Clw==",
    "w6ViBXZlQg==",
    "UwPCucKQCgU=",
    "UMOeZgs=",
    "MTLCtW7Dq2o=",
    "wqAQwr/DqcOi",
    "DiLDtsOOZsKEbsOrGm03EcKEwr/CplQ=",
    "dzPDnRhP",
    "wplgT8KBwow=",
    "XUzCg8KF",
    "K8KTCcKrCQ==",
    "w6ZKJMOw",
    "LxTCmn/DsA==",
    "wooObcKBw6g=",
    "w5djwofDoTQ=",
    "VMOHeAts",
    "Kw96w7bDig==",
    "wogpw6crwps=",
    "PDzDn8OcWQ==",
    "wrfCoWxfw4E=",
    "wrrDv8KDwoI+",
    "w7hnwrjCssOq",
    "w4LDrMOwwpMp",
    "S2vCvyjCjic=",
    "w6DDoT7CtcKNwoo=",
    "wp1Lw5zCpj4=",
    "RsOEGcKVwps=",
    "woxlwo0twoM=",
    "MAZYw7TDmg==",
    "w7ENEC7CgA==",
    "wolVw4jCryEqVMOYdg==",
    "wp45w6cCwqY=",
    "w6UhVHs1",
    "QBZFW8KH",
    "Ozhvw7vDkQ==",
    "E8O4DAXCnA==",
    "AcOXR8OZ",
    "w4NhwqbCk8O6",
    "f8OyScKpRRJTBQd9w4t3PgzCtRMQwrjDrUZ9Z8Od",
    "A8OHw7Inwoc=",
    "wqlQE8KHDg==",
    "wqYbZMOVMg==",
    "w57DuVwAw60=",
    "W8OyQMKtVAk=",
    "w60PBwXCng==",
    "w4h7w70gw55WbHfDuR0VQ8K+asOxwoJn",
    "w5rDhMK2w5gX",
    "N0HCklc=",
    "w58TTsK4wrg=",
    "w7dXNMOhw79pwqBMw70=",
    "SsKQCcKf",
    "KSXCumrDug==",
    "woc1w7gUwrEEw7s=",
    "wplowqIvwoFGMQ==",
    "acO9DcK+",
    "UMKBwpJNwp1ZfA==",
    "wpV+NsKCLQ==",
    "w5PDrMOrwo4iwrcU",
    "XHjCoyPCkw==",
    "w5kOUsKkwqXCqcKm",
    "QMKRAcKDDMK+AA==",
    "bMKoNcKgwrc=",
    "w6k0HTPClw==",
    "wpUYYcOcBA==",
    "w6k6BjnCnMK9",
    "w5HDnncPw60=",
    "jEsjiamLiI.coRVzmBz.v6gWBKxrg=="
]

_token_key = {
    "words": [
        892813624,
        959530041,
        927281971,
        843135300
    ],
    "sigBytes": 16
}

_token_iv = {
    "words": [
        828649523,
        1684300855,
        1684287586,
        842098022
    ],
    "sigBytes": 16
}


const CryptoJS = require("crypto-js");

var _0x17f1 = function (_0x3abb24, _0x9f8a97) {
    _0x3abb24 = ~~'0x'['concat'](_0x3abb24);
    var _0x411694 = _0x175e[_0x3abb24];
    if (_0x17f1['nIHPps'] === undefined) {
        (function () {
            var _0x264909 = typeof window !== 'undefined' ? window : typeof process === 'object' && typeof require === 'function' && typeof global === 'object' ? global : this;
            var _0x52b78f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
            _0x264909['atob'] || (_0x264909['atob'] = function (_0x202c2d) {
                    var _0x2e97e4 = String(_0x202c2d)['replace'](/=+$/, '');
                    for (var _0x488147 = 0x0, _0x1702c1, _0x5d977a, _0x1a87f9 = 0x0, _0x2378be = ''; _0x5d977a = _0x2e97e4['charAt'](_0x1a87f9++); ~_0x5d977a && (_0x1702c1 = _0x488147 % 0x4 ? _0x1702c1 * 0x40 + _0x5d977a : _0x5d977a,
                    _0x488147++ % 0x4) ? _0x2378be += String['fromCharCode'](0xff & _0x1702c1 >> (-0x2 * _0x488147 & 0x6)) : 0x0) {
                        _0x5d977a = _0x52b78f['indexOf'](_0x5d977a);
                    }
                    return _0x2378be;
                }
            );
        }());
    }
}


function v_encrypt(_0x40b5a1, _0x247525, _0x40a45a) {

    return CryptoJS[_0x17f1('6c', 'mXi8')][_0x17f1('6d', 'd]zb')](_0x40b5a1, _0x247525, {
        'iv': _0x40a45a,
        'mode': CryptoJS['mode'][_0x17f1('6e', 'MCwr')]
    })[_0x17f1('6f', 'twtP')]();
}

function v_decrypt(_0x2f61c9, _0x14dd13, _0x2bf4a2) {

    return CryptoJS[_0x17f1('70', '4ozi')][_0x17f1('71', '4jGV')](_0x2f61c9, _0x14dd13, {
        'iv': _0x2bf4a2
    })[_0x17f1('72', 'GR1J')](CryptoJS[_0x17f1('69', 'wW&e')][_0x17f1('73', 'qYmy')]);
}

function getVideoInfo(_0x285840) {
    var _0x588f2c = {
        'FXkAn': function (_0x2c724c, _0x31dd0e, _0x1319b1, _0x54639c) {
            return _0x2c724c(_0x31dd0e, _0x1319b1, _0x54639c);
        },
        'QIHdH': function (_0x6d6414, _0x56d335, _0x37bcd1, _0x10e641) {
            return _0x6d6414(_0x56d335, _0x37bcd1, _0x10e641);
        }
    };
    return _0x588f2c['FXkAn'](v_encrypt, _0x588f2c['QIHdH'](v_decrypt, _0x285840, _token_key, _token_iv), _token_key, key_token);
}

console.log(getVideoInfo())

代码是我从网上扣下来的复制运行即可遇到我所说的(js代码)

阅读 852
avatarAI BotBETA

解决方案

这个问题通常发生在Node.js环境中,尤其是在处理模块导入时。错误提示 Cannot find module 'crypto-js' 表明Node.js无法在其模块路径中找到 crypto-js 模块,而 ReferenceError: CryptoJS is not defined 则表明即使你尝试导入模块,导入也没有成功。以下是一些可能的解决步骤:

  1. 确认 crypto-js 是否已正确安装
    确保你在正确的项目目录下运行了 npm install crypto-js。你可以通过运行 npm list crypto-js 来检查 crypto-js 是否列在已安装的依赖中。
  2. 检查 node_modulespackage.json
    查看项目目录下的 node_modules 文件夹中是否存在 crypto-js 文件夹,同时检查 package.json 文件中的 dependencies 部分是否包含 "crypto-js": "^x.x.x"(x.x.x 是版本号)。
  3. 检查导入语句
    你的导入语句 const CryptoJS = require("crypto-js"); 是正确的,前提是 crypto-js 已正确安装。确保没有拼写错误。
  4. 清理和重新安装依赖
    有时候,依赖可能会因为各种原因没有正确安装。你可以尝试删除 node_modules 文件夹和 package-lock.json 文件,然后重新运行 npm install 来安装所有依赖。
  5. 检查Node.js和npm版本
    确保你的Node.js和npm版本是最新的,或者至少是兼容 crypto-js 的版本。
  6. 运行环境问题
    如果你是在某些特殊的IDE或代码编辑器中运行代码,确保它们配置为使用正确的Node.js解释器。
  7. 代码执行方式
    确保你是通过Node.js来运行这个脚本的,即使用命令 node your_script.js

如果以上步骤都检查过了还是存在问题,可以尝试创建一个简单的测试脚本来单独测试 crypto-js 的导入,看看是否能够成功:

const CryptoJS = require("crypto-js");
console.log(CryptoJS);

如果这个简单的测试脚本可以运行并打印出 CryptoJS 对象,那么问题可能出在你的原始脚本的其他部分。如果测试脚本也失败,那么问题很可能与Node.js环境或 crypto-js 的安装有关。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏