Welcome to the Linux Foundation Forum!

fastify-sensible now part of npm init fastify

Hi @davidmarkclements,

I have noticed that a few weeks ago, fastify-sensible is now part of the auto-generated content from $ npm init fastify, and loaded in the plugins/sensible.js file. This conflicts with some of the content of the course. If you follow some of the given instructions and you try to register it in the app.js file, the application won't start - you will get a FastifyError [Error]: The decorator 'httpErrors' has already been added!, because you are registering it twice:

  • one in the autogenerated plugins/sensible.js file,
  • and the second in the app.js.

This is the case, at least, of the section 5 (Implementing a RESTful JSON GET with Fastify).

For anyone getting this issue, the fix is simple:

  • Either you remove the plugin/sensible.js file
  • Either you don't register fastify-sensible in the app.js file

Comments

Categories

Upcoming Training