midwayjs / midway

🍔 A Node.js Serverless Framework for front-end/full-stack developers. Build the application for next decade. Works on AWS, Alibaba Cloud, Tencent Cloud and traditional VM/Container. Super easy integrate with React and Vue. 🌈
https://www.midwayjs.org/
MIT License
7.4k stars 576 forks source link

midwayjs 3.12.0 使用typegoose start阶段正常运行,build后的产物无法正常运行 #3347

Closed enjoylee-lionjoy closed 1 year ago

enjoylee-lionjoy commented 1 year ago

🐛 Describe the bug(描述 bug)

我使用的是 mongodb + rabbitMQ的方式 在configuration.ts文件中 移除了 koa/egg 代码 仅把midway当作 用于处理 消息队列的服务端。 当我使用 dev模式运行时 只是有 Setting "Mixed" for property "mail.status" Look here for how to disable this message: https://typegoose.github.io/typegoose/docs/api/decorators/model-options/#allowmixed 这样的报错。但会正常的消费消息。 当我编译后 使用 cross-env NODE_ENV=production node ./bootstrap.js 或 NODE_ENV=production node ./bootstrap.js 运行时 在不接收消息队列时 也是正常的 但有消息时 就会报错。 具体报错信息 和代码如下。 不是 很长 很好复现 gist 代码

Midway Versions(Midway 版本)

✓ @midwayjs/faas-typings(not installed) ✓ @midwayjs/fc-starter(not installed) ✓ @midwayjs/serverless-http-parser(not installed) ✓ @midwayjs/async-hooks-context-manager(3.12.3) ✓ @midwayjs/axios(not installed) ✓ @midwayjs/bootstrap(3.12.5) ✓ @midwayjs/bull(not installed) ✓ @midwayjs/bull-board(not installed) ✓ @midwayjs/cache(not installed) ✓ @midwayjs/captcha(not installed) ✓ @midwayjs/casbin(not installed) ✓ @midwayjs/casbin-redis-adapter(not installed) ✓ @midwayjs/casbin-typeorm-adapter(not installed) ✓ @midwayjs/code-dye(not installed) ✓ @midwayjs/consul(not installed) ✓ @midwayjs/core(3.12.3) ✓ @midwayjs/cos(not installed) ✓ @midwayjs/cron(not installed) ✓ @midwayjs/cross-domain(not installed) ✓ @midwayjs/decorator(3.12.3) ✓ @midwayjs/etcd(not installed) ✓ @midwayjs/express-session(not installed) ✓ @midwayjs/faas(not installed) ✓ @midwayjs/grpc(not installed) ✓ @midwayjs/http-proxy(not installed) ✓ @midwayjs/i18n(3.12.7) ✓ @midwayjs/info(3.12.7) ✓ @midwayjs/jwt(not installed) ✓ @midwayjs/kafka(not installed) ✓ @midwayjs/leoric(not installed) ✓ @midwayjs/mikro(not installed) ✓ @midwayjs/mock(3.12.3) ✓ @midwayjs/mongoose(3.12.7) ✓ @midwayjs/oss(not installed) ✓ @midwayjs/otel(not installed) ✓ @midwayjs/passport(not installed) ✓ @midwayjs/process-agent(not installed) ✓ @midwayjs/prometheus(not installed) ✓ @midwayjs/prometheus-socket-io(not installed) ✓ @midwayjs/rabbitmq(3.12.3) ✓ @midwayjs/redis(not installed) ✓ @midwayjs/security(not installed) ✓ @midwayjs/sequelize(not installed) ✓ @midwayjs/session(3.12.3) ✓ @midwayjs/socketio(not installed) ✓ @midwayjs/static-file(not installed) ✓ @midwayjs/swagger(not installed) ✓ @midwayjs/tablestore(not installed) ✓ @midwayjs/tags(not installed) ✓ @midwayjs/typegoose(3.12.7) ✓ @midwayjs/typeorm(not installed) ✓ @midwayjs/upload(not installed) ✓ @midwayjs/validate(3.12.7) ✓ @midwayjs/version(3.12.7) ✓ @midwayjs/view(not installed) ✓ @midwayjs/view-ejs(not installed) ✓ @midwayjs/view-nunjucks(not installed) ✓ @midwayjs/web(not installed) ✓ @midwayjs/express(not installed) ✓ @midwayjs/koa(3.12.3) ✓ @midwayjs/ws(not installed)


Check complete, all versions are healthy.


"@midwayjs/rabbitmq": "^3.12.3", "@midwayjs/typegoose": "^3.12.7", "@midwayjs/validate": "^3.12.0", "@typegoose/typegoose": "^8.0.0", "amqp-connection-manager": "^4.1.14", "amqplib": "^0.10.3", "mongoose": "^5.13.3"

czy88840616 commented 1 year ago

大概率是配置中只写了加载ts的model

enjoylee-lionjoy commented 1 year ago

很大概率是配置中只写了加载ts的模型

哪个配置文件 tsconfig.json么?没动过这个文件 { "compileOnSave": true, "compilerOptions": { "target": "es2018", "module": "commonjs", "moduleResolution": "node", "experimentalDecorators": true, "emitDecoratorMetadata": true, "inlineSourceMap":true, "noImplicitThis": true, "noUnusedLocals": true, "stripInternal": true, "skipLibCheck": true, "pretty": true, "declaration": true, "forceConsistentCasingInFileNames": true, "typeRoots": [ "./typings", "./node_modules/@types"], "outDir": "dist" }, "exclude": [ "dist", "node_modules", "test" ] }

czy88840616 commented 1 year ago

config.default

czy88840616 commented 1 year ago

image

enjoylee-lionjoy commented 1 year ago

image

感谢大佬,解释这种沙雕问题。已经正常运行。