打包项目如下:
dist
-- public(该目录下放了iconv-lite库)
-- static
-- index.html
-- netcard.png
-- plugin.json
-- preload.js
preload.js如下,
`
const iconv = (text) => {
return require('./public/iconv-lite').decode(text, 'gbk');
}
window.services = {
iconv: (text) => {
return iconv(text)
},
}
`
自己try() catch()到报错信息如下,确认是引用iconv-lite导致的问题,了解到iconv-lite库引用了第三方库safer-buffer
Error: Cannot find module 'safer-buffer'
Require stack:
- C:\Users\Administrator\AppData\Roaming\uTools\plugins\unsafe-c885303bb755cc60b16d4caf6963e9e4.asar\public\iconv-lite\lib\index.js
- C:\Users\Administrator\AppData\Roaming\uTools\plugins\unsafe-c885303bb755cc60b16d4caf6963e9e4.asar\preload.js
这个是iconv-lite模块的git地址:
https://github.com/ashtuchkin/iconv-lite
请问应该如何处理,将'safer-buffer文件夹放到public路径下重新打包安装也无效