electron-vite/electron-vite-react

Unable to use koa packages

LengJunT opened this issue · 5 comments

System:macos Ventura 13.5
Node: v16.20.2
pnpm: v8.7.1

An error will be reported after using koa, @ koa/ router, @ koa/ bodyparser, @ koa/ cors, @ koa/ multer build.

使用koa, @koa/router, @koa/bodyparser, @koa/cors, @koa/multer build之后运行会报错。

报错代码为:
WX20240103-200300@2x

main/index.ts

import Koa from 'koa';
import Router from '@koa/router';
import bodyParser from '@koa/bodyparser';
import cors from '@koa/cors';
import multer from '@koa/multer';

const koaApp = new Koa();
const router = new Router();

koaApp
  .use(cors({ exposeHeaders: '*' }))
  .use(bodyParser())
  .use(router.routes())
  .use(router.allowedMethods());

router.get('/test', (ctx) => {
    ctx.body = 'test';
  });

package.json

 "dependencies": {
    "@koa/bodyparser": "^5.0.0",
    "@koa/cors": "^5.0.0",
    "@koa/multer": "^3.0.2",
    "@koa/router": "^12.0.1",
    "electron-updater": "^6.1.1",
    "koa": "^2.15.0",
    "koa-body": "^6.0.1",
    "multer": "1.4.5-lts.1"
  },

😕看起来似乎没有问题,请提供最小复现代码仓库链接。

😕看起来似乎没有问题,请提供最小复现代码仓库链接。

拉下来编译后的产物无法运行。就是模版代码拉下来引入了koa的文件。
https://github.com/LengJunT/electron-vite-react-koa

我拉下了,但是我的报错是
image

--import bodyParser from '@koa/bodyparser';
++import { bodyParser } from '@koa/bodyparser';

我拉下了,但是我的报错是 image

--import bodyParser from '@koa/bodyparser';
++import { bodyParser } from '@koa/bodyparser';

是的,这个报错可以这样解决,然后解决bodyParser这个问题之后,重新build就会报我一开始截图的那个错误

我拉下了,但是我的报错是 image

--import bodyParser from '@koa/bodyparser';
++import { bodyParser } from '@koa/bodyparser';

是的,这个报错可以这样解决,然后解决bodyParser这个问题之后,重新build就会报我一开始截图的那个错误

我晚上看下build