收藏
回答

微信小程序中使用iconv-lite包引入报错?

npm install iconv-lite --save

const iconv = require('iconv-lite');

// 假设你有一个GB2312编码的Buffer或Uint8Array类型的变量gb2312Data
let gb2312Data = ...; // 这里应该是你的GB2312编码数据


// 使用iconv-lite将GB2312编码的数据转换为汉字
let utf8Data = iconv.decode(gb2312Data, 'gb2312');


console.log(utf8Data); // 输出转换后的汉字字符串


引入之后编译就报错

页面【pages/deviceDetection/deviceDetection]错误:

 Error: module 'miniprogram_npm/safer-buffer/buffer.js' is not defined, require args is 'buffer'

    at q (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1)

    at r (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1)

    at __REQUIRE__ (index.js?t=wechat&s=1726808096631&v=5578d0db45387fe60c6c624bc121c13e:20)

    at safer.js:77

    at Object.func (safer.js:5)

    at __REQUIRE__ (index.js?t=wechat&s=1726808096631&v=5578d0db45387fe60c6c624bc121c13e:40)

    at safer.js:77

    at safer.js:77

    at WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1

    at p.runWith (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1)(env: Windows,mp,1.06.2405020; lib: 3.5.6)

(anonymous) @ VM3865:11

Error: module 'miniprogram_npm/safer-buffer/buffer.js' is not defined, require args is 'buffer'

    at q (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1)

    at r (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1)

    at __REQUIRE__ (index.js?t=wechat&s=1726808096631&v=5578d0db45387fe60c6c624bc121c13e:20)

    at safer.js:77

    at Object.func (safer.js:5)

    at __REQUIRE__ (index.js?t=wechat&s=1726808096631&v=5578d0db45387fe60c6c624bc121c13e:40)

    at safer.js:77

    at safer.js:77

    at WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1

    at p.runWith (WASubContext.js?t=wechat&s=1726808096631&v=3.5.6:1)(env: Windows,mp,1.06.2405020; lib: 3.5.6)

Component is not found in path "wx://not-found".(env: Windows,mp,1.06.2405020; lib: 3.5.6)

最后一次编辑于  09-20
回答关注问题邀请回答
收藏

1 个回答

  • ikrins-zero
    ikrins-zero
    09-21

    解决了吗兄弟,我这边也是这个问题

    09-21
    有用
    回复
登录 后发表内容