FastifyError [Error]: fastify-plugin: @fastify/formbody - expected '^4.0.0' fastify version, '3.29.0' is installed

Viewed 1851

Recently i update my @fastify/formbody pluggin but now im having an error about a version mismatch:

FastifyError [Error]: fastify-plugin: @fastify/formbody - expected '^4.0.0' fastify version, '3.29.0' is installed
    at Object.checkVersion (/Users/amargopastor/Projects/blog/node_modules/fastify/lib/pluginUtils.js:107:63)
    at Object.registerPlugin (/Users/amargopastor/Projects/blog/node_modules/fastify/lib/pluginUtils.js:121:16)
    at Boot.override (/Users/amargopastor/Projects/blog/node_modules/fastify/lib/pluginOverride.js:28:57)
    at Plugin.exec (/Users/amargopastor/Projects/blog/node_modules/avvio/plugin.js:80:33)
    at Boot.loadPlugin (/Users/amargopastor/Projects/blog/node_modules/avvio/plugin.js:274:10)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'FST_ERR_PLUGIN_VERSION_MISMATCH',
  statusCode: 500
}

Those are my dependencies on package.json:

{
  "name": "blog",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "dev": "nodemon src/server.ts",
  },
  "dependencies": {
    "@fastify/formbody": "^7.0.0",
    "fastify": "^3.29.0",
    "nodemon": "^2.0.15",
    "pino": "^7.6.3",
    "pino-pretty": "^7.2.0",
    "ts-node": "^10.8.0",
    "ts-node-dev": "^2.0.0",
    "typescript": "^4.7.2"
  }
}

And this is my code:

import fastify from "fastify";
import pino from "pino";
import { main_app } from "./app"
import { PORT } from "./config";

const server = fastify({
    logger: pino({
        name: "blog",
        transport: {
            target: "pino-pretty",
            options: {
                translateTime: true,
                ignore: "time,pid,hostname,reqId",
                colorize: true,
            },
        },
    }),
    disableRequestLogging: true,
});

server.register(main_app)

server.listen(PORT, "0.0.0.0");
import { FastifyPluginAsync } from "fastify";
import formBodyPlugin from "@fastify/formbody";

export const main_app: FastifyPluginAsync = async (app) => {
    app.register(formBodyPlugin);
}

Anybody have similar issues? I asume that there is no '^4.0.0' fastify version.

1 Answers

When you have mismatch version issues, you may rely on the Github repository.

Looking at the releases page you need to install formbody v6.x:

npm install @fastify/formbody@6

or install the upcoming fastify v4:

npm install fastify@next
Related