#Nest 11 upgrade issues?

17 messages · Page 1 of 1 (latest)

drifting crystal
#

I'm seeing a number of type errors upon updating to 11

This says there shouldn't be any change to how fastify/helmet is registered as a plugin: https://docs.nestjs.com/security/helmet#use-with-fastify

But I'm getting an error 😕

src/main.ts:48:22 - error TS2345: Argument of type 'FastifyHelmet' is not assignable to parameter of type 'FastifyPluginCallback<FastifyHelmetOptions> | FastifyPluginAsync<FastifyHelmetOptions> | Promise<...> | Promise<...>'.
  Type 'FastifyHelmet' is not assignable to type 'FastifyPluginCallback<FastifyHelmetOptions>'.
    Types of parameters 'instance' and 'instance' are incompatible.
      Type 'FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>' is missing the following properties from type 'FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>': getDefaultRoute, setDefaultRoute, multipartErrors, serializeCookie, and 3 more.

48   await app.register(helmet)
                        ~~~~~~
copper tundra
#

I just tested the code snippet mentioned in the docs and it worked fine here
So I guess you should see the output of npm ls fastify

#

and make sure that @fastify/helmet being used is v13

drifting crystal
#

Helmet 13 is def there..

copper tundra
#

what about npm ls fastify? don`t grep

drifting crystal
#

That didn't bring up the helmet version, that's why I went w/ the grep approach

copper tundra
#

ok, that's the issue

#

looks like you have fastify installed as a hard dep on your project, and so you must align its version if the version from @nestjs/platform-fastify
Or just run npm uninstall fastify

drifting crystal
#

ok.. let me try that

#

Hmmm... So.. It's not letting me take either of those approaches.. 😕

copper tundra
#

it's uninstall, not install

#

make sure you've upgraded every @nestjs/* package as well

#

npx nest info

drifting crystal
#

did I type install by mistake? 🤦‍♂️

#

Oh no. I didn't.. says it right there..

npm uninstall fastify

#

Ah.. looks like I missed a couple of Nest packages in the upgrade in my devDeps.. let me try updating those

drifting crystal
#

Ok.. after hours of fighting w/ this.. appears to be a circular out-of-date dependencies issue that NPM just was refusing to reconcile for me..

I nuked my node_modules, and manually updated the package.json file to update the appropriate packages, and now all is working as expected.

Thanks for the patience and help @copper tundra !