编辑器三方插件JSEncrypt无法加载

  • Creator 版本:3.0.0

  • 目标平台: 无
    如图

  • 重现方式:
    新建的空项目,导入插件, npm install jsencrypt
    新建ts脚本使用插件
    import JSEncrypt from ‘jsencrypt’
    start () {
    const rsaEncryptor = new JSEncrypt({});
    rsaEncryptor.setPublicKey(“publicKey”);
    return rsaEncryptor.encrypt(“content”);
    }
    image

  • 首个报错:
    [Scene] 未发现打包后的资源:node_modules/jsencrypt/lib/JSEncrypt
    at QuickPackLoader.getResourceFromId (E:\Program Files\CocosDashboard\resources.editors\Creator\3.0.0\resources\app.asar\node_modules@editor\lib-programming\dist\mod-assembling\quick-pack\loader.js:62:19)
    at PackModInstantiation.instantiate (E:\Program Files\CocosDashboard\resources.editors\Creator\3.0.0\resources\app.asar\node_modules@editor\lib-programming\dist\executor\pack-mod-instantiation.js:29:58)
    at async E:\Program Files\CocosDashboard\resources.editors\Creator\3.0.0\resources\app.asar\node_modules@editor\lib-programming\dist\executor\index.js:87:34
    at async ExecutorSystem._instantiate (E:\Program Files\CocosDashboard\resources.editors\Creator\3.0.0\resources\app.asar\node_modules@editor\lib-programming\dist\editor-systemjs\index.js:90:30)

退出重新打开时报错:
无法加载模块 file:///C:/Users/xxx/JSEncryptDemo/node_modules/jsencrypt/lib/JSEncrypt :Error: 在加载模块文件 C:\Users\xxx\JSEncryptDemo\node_modules\jsencrypt\lib\JSEncrypt 时发生错误:Error: ENOENT: no such file or directory, open ‘C:\Users\AlexChen\JSEncryptDemo\node_modules\jsencrypt\lib\JSEncrypt’.

[Scene] 未发现打包后的资源:node_modules/jsencrypt/lib/JSEncrypt
at QuickPackLoader.getResourceFromId (E:\Program Files\CocosDashboard\resources.editors\Creator\3.0.0\resources\app.asar\node_modules@editor\lib-programming\dist\mod-assembling\quick-pack\loader.js:62:19)
at PackModInstantiation.instantiate (E:\Program Files\CocosDashboard\resources.editors\Creator\3.0.0\resources\app.asar\node_modules@editor\lib-programming\dist\executor\pack-mod-instantiation.js:29:58)
at async E:\Program Files\CocosDashboard\resources.editors\Creator\3.0.0\resources\app.asar\node_modules@editor\lib-programming\dist\executor\index.js:87:34
at async ExecutorSystem._instantiate (E:\Program Files\CocosDashboard\resources.editors\Creator\3.0.0\resources\app.asar\node_modules@editor\lib-programming\dist\editor-systemjs\index.js:90:30)

  • 之前哪个版本是正常的: 2.4.4
  • 手机型号: 无
  • 手机浏览器: 无
  • 编辑器操作系统: windows 10
  • 重现概率: 稳定
1赞

相同问题,可能要改兼容~

可以试试使用它的 web 版本,import JSEncrypt from ‘jsencrypt/bin/jsencrypt.js’;