Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use koa packages #192

Open
LengJunT opened this issue Jan 3, 2024 · 5 comments
Open

Unable to use koa packages #192

LengJunT opened this issue Jan 3, 2024 · 5 comments
Labels
need info More information needed

Comments

@LengJunT
Copy link

LengJunT commented Jan 3, 2024

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"
  },
@RSS1102
Copy link
Member

RSS1102 commented Jan 4, 2024

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

@RSS1102 RSS1102 added the need info More information needed label Jan 4, 2024
@LengJunT
Copy link
Author

LengJunT commented Jan 8, 2024

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

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

@RSS1102
Copy link
Member

RSS1102 commented Jan 10, 2024

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

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

@LengJunT
Copy link
Author

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

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

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

@RSS1102
Copy link
Member

RSS1102 commented Jan 11, 2024

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

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

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

我晚上看下build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need info More information needed
Projects
None yet
Development

No branches or pull requests

2 participants