bun
bun copied to clipboard
Support NestJS
This is a tracking issue to get bun's node.js compatibility far enough along to support https://nestjs.com/
+1, It would be amazing if Bun would work with NestJS.
+1, also would love this
+10 please !
yes please!
this would be a game changer
+1 would be extremely interesting !!
Where I can start to contribute on this issue?
@muhad-bk We appreciate your enthusiasm! If you could try running a NestJS project in Bun and letting us know what breaks that would be extremely helpful. I'm not sure exactly sure what is missing for NestJS to work yet
AFAIK NestJS relies on repl and the net module. At least these two I still see marked as open in the bun roadmap.
I actually was very curious about this and just got bun
up and running with a fresh install of nestjs
. Am toying around with a basic API, I can update as things go to see what breaks.
I actually was very curious about this and just got
bun
up and running with a fresh install ofnestjs
. Am toying around with a basic API, I can update as things go to see what breaks.
I tried it too by using bun to run the distribution directly i.e. bun dist/main.js. It works for static routes. But application failed to start for more complex codes involving typeorm; concretely, a call to require('module').globalPaths along the line, erroneously returns "undefined" and aborts startup.
I actually was very curious about this and just got
bun
up and running with a fresh install ofnestjs
. Am toying around with a basic API, I can update as things go to see what breaks.I tried it too by using bun to run the distribution directly i.e. bun dist/main.js. It works for static routes. But application failed to start for more complex codes involving typeorm; concretely, a call to require('module').globalPaths along the line, erroneously returns "undefined" and aborts startup.
To be more specific, the error was within app-root-path/lib/resolve.js in node_modules, called from typeorm.
To be more specific, the error was within app-root-path/lib/resolve.js in node_modules, called from typeorm.
This error should be fixed once the canary builds (when CI is green)
To upgrade:
bun upgrade --canary
To be more specific, the error was within app-root-path/lib/resolve.js in node_modules, called from typeorm.
This error should be fixed once the canary builds (when CI is green)
To upgrade:
bun upgrade --canary
The globalPaths issue has been fixed. Thank you. Next blocker is lack of http2 implementation by bun. Is http2 support roadmapped yet?
If you want to build and run your project with Bun, you can:
bun upgrade --canary
package.json:
"start:dev": "nest start --watch --exec \"bun run\"",
nest-cli.json :
"entryFile": "main.js"
(bun didn't like being passed a script without a file extension)
@devongermano
it worked quite well using nest start --watch --exec \"bun run\"
but when running
bun dist/main.js
it return http2 error ( i think its related to my project package somwhere)
Cannot find package "http2" from "/myprojectdir/node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-handler.js"
I think Bun supports Nest.js. I made a simple repro repo here. Though it's a very minimal repo, but it's able to proof that it is possible to use Nest.js with Bun.
I think Bun supports Nest.js. I made a simple repro repo here. Though it's a very minimal repo, but it's able to proof that it is possible to use Nest.js with Bun.
I forked your repo and tried to integrate with Mongoose but it didn't work. I think we still need to wait quite a lot of time until we can use it in production
My experience so far is same as @ntheanh201 says. Unless your app is super simple you will probably get compatibility issues with libs like Mongoose or TypeORM.
wait
Hi folks, what do we need to make the bun compatible with nestjs?
My experience so far is same as @ntheanh201 says. Unless your app is super simple you will probably get compatibility issues with libs like Mongoose or TypeORM.
This week, I will try using prisma and i'll bring my feedback about it.
hope nestjs support natively for bun runtime.
Please put in in a bun!
Has anyone done a test with version 0.6?
Has anyone done a test with version 0.6?
doing this now, 0.6.3 // canary
When running nest start --watch --exec \"bun run\"
it return missing script /dir/dist/main
does bun / nestjs need to explicitly use file type (js,ts) ?
I have tested this in 0.6.3 and I see Bun appears to be having a problem setting the emitDecoratorMetadata
setting. Injected services are undefined in the controller.
Anyone have any ideas on what we can do?
[Nest] 8956 - 05/25/2023, 7:10:01 AM ERROR [ExceptionsHandler] undefined is not an object (evaluating 'this.appService.getHello')
getHello@/Users/austin/Documents/practice/bun-quickstart/src/app.controller.ts:12:57
I also experience some issues with decorators metadata on version 0.6.5
(1388ec0
).
Importing reflect-metadata
does not work, as detailed on issue https://github.com/oven-sh/bun/issues/2979.
This issue is probably a good starting point to improve the compatibility of Bun with frameworks such as NestJS.
Example
import 'reflect-metadata';
import { container, injectable } from 'tsyringe';
@injectable()
class Dependency {
constructor() {
console.log('Someone needs me!');
}
}
@injectable()
class Service {
constructor(dependency: Dependency)
{
console.log('I am the service and this is the dependency:', dependency);
}
}
container.resolve(Service);
Edit
It now seems to work on 0.6.5
(https://github.com/oven-sh/bun/commit/756e15f6e283fd7e21fe91e060d63440ce5c72de), thanks!
It doesn't work for me, even with Canary
nest start --watch --exec \"bun run\"
bin/bash: nest: command not found
error: script "start:bun" exited with code 127