【发布时间】:2021-08-14 17:18:50
【问题描述】:
我的 NestJs 应用出现问题。项目一直运行到昨天为止。
显然我的 node.js 从14.16.1 升级到14.17.0。所以我在engines 对象中更改了这个版本号,在package.json 中。我再次执行了yarn install,以确保一切都在那里,并尝试了yarn start:dev(转换为nest start --watch)。
但是我的应用没有运行 =( 我的 apollo-server-fastify 似乎有问题:
UnhandledPromiseRejectionWarning: Error: You must `await server.start()` before calling `server.createHandler()`
at ApolloServer.assertStarted (/app/node_modules/apollo-server-fastify/node_modules/apollo-server-core/dist/ApolloServer.js:213:19)
at ApolloServer.createHandler (/app/node_modules/apollo-server-fastify/dist/ApolloServer.js:22:14)
at GraphQLModule.<anonymous> (/app/node_modules/@nestjs/graphql/dist/graphql.module.js:150:45)
at Generator.next (<anonymous>)
at /app/node_modules/tslib/tslib.js:117:75
at new Promise (<anonymous>)
at Object.__awaiter (/app/node_modules/tslib/tslib.js:113:16)
at GraphQLModule.registerFastify (/app/node_modules/@nestjs/graphql/dist/graphql.module.js:143:24)
at GraphQLModule.<anonymous> (/app/node_modules/@nestjs/graphql/dist/graphql.module.js:118:28)
at Generator.next (<anonymous>)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:323734) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:323734) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我知道 apollo 和 fastify 现在不是最好的朋友,我想我过去曾遇到过需要降级某些软件包的问题。有谁知道如何调试/修复这个?我觉得一头雾水。 当前软件包版本:
"@nestjs/common": "^7.0.0",
"@nestjs/graphql": "^7.7.0",
"@nestjs/platform-fastify": "^7.6.4",
"apollo-server-fastify": "^3.0.0-alpha.3",
"graphql": "^15.5.0",
(我也尝试将 apollo-server-fastify 升级到 alpha 4,但问题仍然存在)。
【问题讨论】:
-
检查问题是否是this one
-
我猜不是。再次尝试
yarn install,没有任何改变。然后我发现 fastify 不是 nestjs 项目的直接依赖。打开它的 node_modules 目录,它的当前版本是 3.14.0。所以最近没更新
标签: node.js nestjs apollo-server fastify