koajs / koa-body

koa body parser middleware
MIT License
947 stars 131 forks source link

formidable 2.0.1 has some wrong #224

Closed RookieGz closed 1 year ago

RookieGz commented 1 year ago

Describe the bug

截屏2023-01-05 14 59 40

Node.js version: v16.19.0

OS version: macOS Ventura 13.1

Description:

i try to package a nodejs app with webpack5, but when the app running has a error:

hexoid is not a function

I notice has a formidable 2.0.1, Maybe it's a bug with this package

formidable 2.0.1

Actual behavior

Expected behavior

Code to reproduce

Checklist

RookieGz commented 1 year ago

If I'm wrong please close this issue

wxfred commented 1 year ago

Any solution, pls?

RookieGz commented 1 year ago

@wxfred add this code in webpack.config.js plugins: [ new NormalModuleReplacementPlugin( /^hexoid$/, require.resolve("hexoid/dist/index.js") ), ],

wxfred commented 1 year ago

@wxfred add this code in webpack.config.js plugins: [ new NormalModuleReplacementPlugin( /^hexoid$/, require.resolve("hexoid/dist/index.js") ), ],

Not work for me, but really helpful to locate the problem -- webpack5 uses hexoid/dist/index.mjs by default while formidable uses it as a CommonJS module. I'm using vue-cli-plugin-electron-builder, finally, i found a work around in vue.config.js

module.exports = {
  pluginOptions: {
    electronBuilder: {
      chainWebpackMainProcess(config) {
        config.resolve.alias
          .set('hexoid', 'hexoid/dist/index.js')

Thanks a lot.