Nest framework TypeScript starter repository.
Note: This is a testing running Nest.js with Bun
nestjs-bun-test on main [?] via 🍞 v0.6.7 via v20.2.0 ❯ neofetch -``````````` iiaku@iiaku-desktop `-+/------------.` ------------------- .---:mNo---------------. OS: Solus x86_64 .-----yMMMy:---------------. Host: MS-7C96 1.0 `------oMMMMMm/----------------` Kernel: 6.3.4-237.current .------/MMMMMMMN+----------------. Uptime: 1 day, 14 hours, 46 mins .------/NMMMMMMMMm-+/--------------. Packages: 893 (eopkg), 29 (flatpak) `------/NMMMMMMMMMN-:mh/-------------` Shell: zsh 5.9 .-----/NMMMMMMMMMMM:-+MMd//oso/:-----. Resolution: 5120x1440 -----/NMMMMMMMMMMMM+--mMMMh::smMmyo:-- DE: GNOME 43.5 ----+NMMMMMMMMMMMMMo--yMMMMNo-:yMMMMd/. WM: Mutter .--oMMMMMMMMMMMMMMMy--yMMMMMMh:-yMMMy-` WM Theme: Materia-dark `-sMMMMMMMMMMMMMMMMh--dMMMMMMMd:/Ny+y. Theme: Adwaita [GTK2/3] `-/+osyhhdmmNNMMMMMm-/MMMMMMMmh+/ohm+ Icons: Papirus [GTK2/3] .------------:://+-/++++++oshddys: Terminal: gnome-terminal -hhhhyyyyyyyyyyyhhhhddddhysssso- CPU: AMD Ryzen 7 3700X (16) @ 3.600GHz `:ossssssyysssssssssssssssso:` GPU: AMD ATI Radeon RX 6800/6800 XT / 6900 XT `:+ssssssssssssssssssss+- Memory: 17489MiB / 32029MiB `-/+ssssssssssso+/-` `.-----..` nestjs-bun-test on main [+] via 🍞 v0.6.7 via v20.2.0 ❯ node -v v20.2.0 nestjs-bun-test on main [+] via 🍞 v0.6.7 via v20.2.0 ❯ bun -v 0.6.7 nestjs-bun-test on main [+] via 🍞 v0.6.7 via v20.2.0 ❯ nest -v 9.5.0
Created project with
$ nest new nestjs-bun-test
Then installed packages with:
$ bun install
Built project with
$ bun build
This will basically run nest build
so will build as usual
Ran project with
$ bun start:prod
This won't work
nestjs-bun-test on main [?] via 🍞 v0.6.7 via v20.2.0 ❯ bun start:prod $ bun dist/main.js [Nest] 139970 - 06/03/2023, 2:55:00 PM LOG [NestFactory] Starting Nest application... [Nest] 139970 - 06/03/2023, 2:55:00 PM LOG [InstanceLoader] AppModule dependencies initialized +9ms [Nest] 139970 - 06/03/2023, 2:55:00 PM LOG [RoutesResolver] AppController {/}: +5ms [Nest] 139970 - 06/03/2023, 2:55:00 PM LOG [RouterExplorer] Mapped {/, GET} route +1ms [Nest] 139970 - 06/03/2023, 2:55:00 PM LOG [NestApplication] Nest application successfully started +2ms error: script "start:prod" exited with code 11 (SIGSEGV)
$ bun run dist/main.js
This won't work as well
nestjs-bun-test on main [?] via 🍞 v0.6.7 via v20.2.0 ❯ bun run dist/main.js [Nest] 142771 - 06/03/2023, 3:06:51 PM LOG [NestFactory] Starting Nest application... [Nest] 142771 - 06/03/2023, 3:06:51 PM LOG [InstanceLoader] AppModule dependencies initialized +8ms [Nest] 142771 - 06/03/2023, 3:06:51 PM LOG [RoutesResolver] AppController {/}: +6ms [Nest] 142771 - 06/03/2023, 3:06:51 PM LOG [RouterExplorer] Mapped {/, GET} route +1ms [Nest] 142771 - 06/03/2023, 3:06:51 PM LOG [NestApplication] Nest application successfully started +2ms [1] 142771 segmentation fault (core dumped) bun run dist/main.js
Also passing bun as binary to nest cli won't work
nestjs-bun-test on main [?] via 🍞 v0.6.7 via v20.2.0 ❯ bun start $ nest start nestjs-bun-test --exec \"bun\" error: script not found "/home/iiaku/dev/nestjs-bun-test/dist/main" error: script "start" exited with code 1 (SIGHUP)
However running:
$ bun run src/main.ts
You can also watch changes to "mimic" the start:dev script since that one won't work as well when binding bun's binary
$ bun --watch run src/main.ts
Seems to work, at least starting the server, however the route being called won't work and raise some error. I tried to return something very simple (a string) see /src/app.controller.ts
and it did work. The error was raised, because it seems running src/main.ts does not seems to attach class's service properly as you can see appService
is undefined
when exposing this.
nestjs-bun-test on main [!?] via 🍞 v0.6.7 via v20.2.0 ❯ bun run src/main.ts [0.02ms] ".env" [Nest] 145087 - 06/03/2023, 3:14:56 PM LOG [NestFactory] Starting Nest application... [Nest] 145087 - 06/03/2023, 3:14:56 PM LOG [InstanceLoader] AppModule dependencies initialized +10ms [Nest] 145087 - 06/03/2023, 3:14:56 PM LOG [RoutesResolver] AppController {/}: +5ms [Nest] 145087 - 06/03/2023, 3:14:56 PM LOG [RouterExplorer] Mapped {/, GET} route +2ms [Nest] 145087 - 06/03/2023, 3:14:56 PM LOG [NestApplication] Nest application successfully started +1ms { returning: "hello world", thisValue: { appService: undefined, getHello: [Function: getHello] } } { ENV_LOADED: "true" }