Setting up isolated git, node.js, and npm installations in user directory

I’m looking for a way to create a script that sets up separate installations of git, node.js, and npm in my home directory. I want to do this without needing root access. The main goal is to have different versions for different projects.

Does anyone know if there’s already a tool or script out there that does this? I’ve tried searching but haven’t found anything yet.

It would be great if the script could:

  • Set up isolated environments for different branches or versions
  • Rebuild everything from source each time

I’m not sure if I’m missing some common approach to this problem. Any tips or suggestions would be really helpful. Thanks!

I’ve encountered similar requirements in my work. While there’s no single tool that accomplishes everything you’re after, you might consider a hybrid approach. For git, you can use git-build-recipe to compile specific versions from source. As for Node.js and npm, nvm (Node Version Manager) is excellent for managing multiple versions without root access. To tie it all together, you could write a custom shell script that leverages these tools to create isolated environments on demand. This script could clone the desired git version, use nvm to install the required Node.js/npm versions, and set up appropriate environment variables. It’s not a perfect solution, but it should get you most of the way there without needing root access.

hey Noah, have u tried using Docker? it’s pretty sweet for isolating different versions of stuff. u can create separate containers for each project with the exact versions u need. no need to rebuild from source every time. might be worth checkin out if u haven’t already!

I’ve actually tackled a similar challenge in my work environment. While there’s no single tool I know of that does exactly what you’re looking for, I’ve had success cobbling together a solution using a combination of tools.

For git, I use the ‘git-clone’ command to install specific versions in separate directories. For Node.js and npm, I’ve found ‘nvm’ (Node Version Manager) to be invaluable. It allows you to install and switch between multiple Node.js versions without root access.

As for rebuilding from source, I wrote a custom bash script that pulls the latest source for each tool, compiles it, and installs it in a specified directory. It’s not perfect, but it gets the job done.

One thing to keep in mind is that this approach can be quite resource-intensive, especially if you’re rebuilding frequently. You might want to consider using Docker containers as an alternative - they provide isolation without the overhead of rebuilding everything from scratch each time.

Hope this helps point you in the right direction. Let me know if you need any clarification on the process I’ve described.