Best approach to a NodeJS development environment?

Enjoying the Silverblue version of Fedora so far but the one thing I’m struggling to find a clear path forward with is getting a NodeJS environment up and running for some development work with Svelte and Websockets I’m doing.

My setup is pretty straightforward: I like using VS Code with a few plugins and running my API and front-end in split terminals in VS Code The API connects to a MongoDB instance hosted on server on my local network if that makes a difference at all.

I’m struggling to tie these development components together. What’s the best way to get VS Code and NodeJS going on Silverblue?

1 Like

Hello @jaypeedaylee ,
Welcome to the discussion area. This may be a good place to start Set up a .NET development environment - Fedora Magazine. Though it focuses on Fedora Linux Workstation, on Silverblue you could do all of this in a Toolbox container using dnf as shown. Also this is for .Net development, and uses VSCode for the IDE, but you could just go with whatever IDE you wanted and install it in toolbox as well if needed. I personally use a flatpak IDE (Netbeans) and local or layered bits and the command line for my stuff at this moment. I am intending on making a setup with separate containers in a pod arrangement that becomes my dev environment. I am using the Quarkus framework for my java and it is very exciting.

If you have projects with different settings, I would create a new Toolbox for each project. However, if your projects are similar (i.e. use the same technology stack), I would just create one toolbox for all of them with just the low level part of the stack inside of it. I do Rails development, and I keep Imagemagick, Ruby dependencies (cmake and others) and postgres-devel and vscode inside the Toolbox, and keep the rest contained in project folders in my home directory (outside of the Toolbox, but accessible by Toolbox). I also keep node itself outside, with node and yarn installed with Volta in my home dir. See this thread: Options to install node.js on fedora silverblue

Postgres itself I run in a separate podman container because systemd services are the only things that are problematic inside Toolbox. I don’t know enough about how Mongo works to say what’s the best solution for your needs.

This way I get access to all the necessary tools without flatpak spawn and I avoid the issues you get with sandboxes and IDEs. Very happy with this “intermediate” container setup - having full access to the host while still being able to just podman rm toolboxname hits the sweet spot between ease of use and containerised workflow, in my opinion. I used to use Vagrant, but this is faster and better. I also wrote an Ansible playbook for faster setup of the Toolbox.

2 Likes

Hello @evenreven ,
Slightly off topic here, but not quite. Have you tried Deno as an open source alternative to node.js?

1 Like

Thanks for the help guys!

I wound up going back to normal Fedora for the time being. Ultimately just needed to get going with my project. That said I am pretty excited for Silverblue as it sounds like it could be a game changer for the future for Fedora (and other Linux based OSs!).

Might even just put up a VM just to have access to Silverblue so I can learn the system in my down time.

As for Deno, I haven’t tried it YET. I do have some interest in doing so but NodeJS has a much larger community at the moment so it’s easier to find help when I need it.

1 Like

Deno is promising, and I might try it for a hobby project. But I don’t want to be an early adopter on production apps when node is working quite well. Maybe in a year or two. Also, pretty sure it’s far from being compatible with any kind of real frontend bundler setup, which is what I would be using it for. Vite does not support it, and webpack (which is knee deep in an old-ish node tech stack) probably won’t for years, if ever.

Yeah it is a bit young yet. The API would change the way it would need to be used. I like the security as default and the sandbox as default approach. Plus I find the use of modules by pointing to URL’s less cumbersome than NPM.

Hi, @jaypeedaylee. If you install VSCode from flatpak (I use com.vscodium.codium version), then it is supposed to find automatically and use the additional SDK extensions installed via flatpak ( like org.freedesktop.Sdk.Extension.dotnet, and org.freedesktop.Sdk.Extension.node14)

I am using such a setup for some small .Net demos, that have some NodeJS based modules added in, but VSCode is not my main IDE and such a setup might be missing many things that I never needed but you might. Just try and see for yourself.

There is an article from Redhat Developer https://developers.redhat.com/blog/2019/09/13/develop-with-node-js-in-a-container-on-red-hat-enterprise-linux#testing_redis_from_the_node_js_container