最近,我更新了我的@fastify/formbody插件,但是现在我有一个关于版本不匹配的错误:
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
}这些是我对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"
}
}这是我的密码:
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);
}有人有类似的问题吗?我认为没有'^4.0.0‘法西斯版本。
发布于 2022-05-31 07:01:36
当您有不匹配的版本问题时,您可能会依赖Github存储库。
查看一下发布页面,您需要安装formbody v6.x:
npm install @fastify/formbody@6或者安装即将发布的fastify v4:
npm install fastify@nexthttps://stackoverflow.com/questions/72438159
复制相似问题