Comments (3)
can you provide a repro?
I could create new route without any problem.
from vite-plugin-node.
+1
C:\pkg\node_modules\.pnpm\[email protected]\node_modules\fastify\lib\route.js:367
throw new FST_ERR_DUPLICATED_ROUTE(opts.method, opts.url)
^
FastifyError [Error]: Method 'POST' already declared for route '/auth/login'
at Object.addNewRoute (C:\pkg\node_modules\.pnpm\[email protected]\node_modules\fastify\lib\route.js:367:19)
at Object.route (C:\pkg\node_modules\.pnpm\[email protected]\node_modules\fastify\lib\route.js:261:19)
at Object.prepareRoute (C:\pkg\node_modules\.pnpm\[email protected]\node_modules\fastify\lib\route.js:167:18)
at Object._post [as post] (C:\pkg\node_modules\.pnpm\[email protected]\node_modules\fastify\fastify.js:270:34)
at FastifyAdapter.injectRouteOptions (C:\pkg\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected]\node_modules\@nestjs\platform-fastify\adapters\fastify-adapter.js:392:46)
at FastifyAdapter.post (C:\pkg\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected]\node_modules\@nestjs\platform-fastify\adapters\fastify-adapter.js:129:21)
at C:\pkg\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected][email protected][email protected]\node_modules\@nestjs\core\router\router-explorer.js:105:17
at Array.forEach (<anonymous>)
at C:\pkg\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected][email protected][email protected]\node_modules\@nestjs\core\router\router-explorer.js:90:29
at Array.forEach (<anonymous>) {
code: 'FST_ERR_DUPLICATED_ROUTE',
statusCode: 500
}
// package.json
"@nestjs/cli": "^10.3.2",
"@nestjs/common": "^10.3.3",
"@nestjs/core": "^10.3.3",
"@nestjs/platform-fastify": "^10.3.3",
"@swc/cli": "^0.3.10",
"@swc/core": "^1.4.2",
"@swc/helpers": "^0.5.6",
"typescript": "^5.3.3",
"vite": "^5.1.4",
"vite-plugin-node": "^3.1.0",
"fastify": "^4.26.1"
// vite.config.ts
import { defineConfig } from "vite";
import { VitePluginNode as vite_plugin_node } from "vite-plugin-node";
export default defineConfig({
plugins: [
...vite_plugin_node({
adapter: "nest",
appPath: "./src/index.ts",
exportName: "App",
tsCompiler: "swc",
initAppOnBoot: true,
}),
],
});
// ./src/index.ts
import { NestFactory } from "@nestjs/core";
import {
FastifyAdapter,
type NestFastifyApplication,
} from "@nestjs/platform-fastify";
import { AppModule } from "./app.module";
import { RawServerDefault } from "fastify";
async function create() {
const adapter = new FastifyAdapter({});
const app: NestFastifyApplication<RawServerDefault> =
await NestFactory.create<NestFastifyApplication>(AppModule, adapter);
return app;
}
export const App = create();
from vite-plugin-node.
It seems that this happens when several requests arrive at one endpoint, for some reason they are processed simultaneously and
at the same time they try to declare these methods.
from vite-plugin-node.
Related Issues (20)
- Nest.js + Fastify: No driver (HTTP) has been selected. HOT 2
- HMR only works after the application web page is reloaded HOT 2
- Add support for Vite 5 HOT 3
- not support parameter decorators HOT 5
- Nest middleware not receiving express Request
- Expose viteNodeApp after async operations HOT 2
- HMR reloads from root - app.ts
- Proposal: Simpler way to bundle Node apps with Vite HOT 1
- NestJS example not working HOT 3
- Can it bundle into a single file?
- `vite build` does not bundle the dependencies HOT 3
- HMR not working, server going through a full reload every time a file changes
- Configuring https server results in an exception HOT 3
- server example HOT 1
- `vite-plugin-node` vs `vite-node` HOT 2
- How to render some routes using Nest and some using Vite? HOT 1
- HMR doesn't work HOT 3
- NestJs Build error - Failed to resolve entry for package "fs"
- I used the nestjs and vite-plugin-node example, they threw this err,,,what makes it so HOT 2
- Module '"http"' has no default export. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vite-plugin-node.