Beautiful Elysia, imprismad in a jail

Simmons Frank
3 min readFeb 22, 2024

--

Think of a beautiful girl with Greek and Latin origins from a place called Elysium, a place of beauty and rich in nature. Greek mythology is fascinating isn’t it.

My story today is about ElysiaJS, BunJS’s web framework that kicks donkeys!! Some time last year I stumbled across it, and as usual I was drawn in by the simple things that captivate my soul, a beautiful to look at, mesmerizing, and crafted with love thing… their website. 🤣

It’s been quite a fun journey learning ElysiaJS these past few months, despite BunJS advertised as “not production ready” (last year), it’s sufficed for what I needed to achieve, as I write this article, we are sitting at a sweet 1.0.28, with updates every other day! 😍

I was confident enough with what I was building with Elysia that I decided to move it up into a docker image and test it out in the world, but only one thing was holding me back, my ORM of choice for this project…

https://www.linkedin.com/pulse/what-prisma-why-you-need-use-your-project-kanon-hosen

For a while now, Prisma was the pain point of this project. Initially Prisma couldn’t “generate” some necessary files on my local machine, eventually I discovered this was due to the fact that Prisma was somehow still dependent on nodeJS in the background — despite Bun being “a drop-in replacement” for NodeJS, not to worry, Bun was fairly new on the market so such was expected. I got node installed on my WSL2 system and wala! all was good, but only locally.

A representation of the blue Docker dolphin logo, using only Lego blocks. By Sean Kenney
image from seankenney.com

Building a Docker image always “silently failed” when it got to the prisma part, I thought maybe I was such a noob and was missing something, but the Bun community too was growing restless of this issue, after reading about a few non-ideal tricks here and there from various Users on Github, I decided to give it a go as well.

Judging by the error logs, the issue was with “@prisma/client” not being found, a folder that was nested within the node_modules folder. Somehow I figured the nested structure was breaking when moving the source files into a docker build (or maybe it was the preceding ‘.’ on the prisma folder — i don’t know). But I saw a comment from Shawn on Stack Overflow that inspired me to tinker.

prisma generator client’s output location — Shawn Gordon Becker

The output file location for the prisma generator client was nested within the node_modules folder, Shawn “pulled it out” into prisma’s configuration folder then copied the entire prisma folder into the docker image, great! that made sense for a while, til i tried it and it still failed, days later after a few LAN races in Blur with my colleague, it hit me! I moved the location of the generated files, but I didn’t point to their new location!!!
I rushed back into VS code, found no errors, then laughed at myself… VSCode automatically re-links files around your project once you rename a file somewhere, damn, I thought I was onto something.

It turns out, pointing the generator client to a new location still leaves a copy of the old files in the old location so no error would be thrown of course because the old location still exists. All I had to do was search for any mention of “@prisma/client” in my source code, and rename it to the new location! Since my new generator location was “../generated/client” (2 dots so I could simply reference the folder with `import { ExampleModel } from 'generated/client'`), meaning the generated folder was now in the project root folder, so all mentions of @prisma/client were edited to “generated/client”. And in the Dockerfile I simply copied the generated folder from my host into the Docker image. 😎

--

--

Simmons Frank

Designer • Animator • Gamer • Editor • VFx Specialist • Semi-Coder • Idealist •