Closed shuangovo closed 3 years ago
I honestly don't know what's going on here. Maybe you can ask in safer-buffer package or webpack?
There are some old pr/issues attempting to remove safe-buffer and replace buffer with uint8array... this would be a good thing
From the error log, this is not sure caused by iconv-lite, but may be caused by webpack,or the version of iconv-lite. by the way,it is recommended that you make a JSFiddle/JSBin/Codepen/CodeSandbox to demonstrate your issue.
@yosion-p It was build success in CodeSandbox.I used the webpack template there.I found it just have one more config about babel,it's '@babel/plugin-transform-runtime'
oh,It was build success just for its webpack version is 4, I got the error in version 5
this is the CodeSandbox: https://codesandbox.io/s/nostalgic-hill-796kb?file=/package.json
oh,It was build success just for its webpack version is 4, I got the error in version 5
I would say that it was caused by webpack5.Some people have encountered this problem in Google.
The problem is resolved.I'm stupid,I always thought the error Error: Cannot find module 'buffer/'
ask me to npm i buffer/
,however,the correct is npm i buffer
.So in webpack5,we should npm i buffer
and add a config into webpack.config.js
resolve: {
fallback: {
'buffer': require.resolve('buffer/')
}
}
when I require iconv-lite and build ,I get the error,
so I add resolve.fallback: { "buffer": require.resolve("buffer/") } to webpack.config.js,but