DEV Community

Adam Crockett πŸŒ€
Adam Crockett πŸŒ€

Posted on

Things to know about Global Dependencies with Dev Containers

Node.js is one of a few runtime that packs the dependencies locally, similar to C where you make dynamic linked libraries etc.
Python, Ruby and others usually store your dependencies system wide.
This idea of local dependencies in Node.js allows us to ship all sorts of things, for better or worse... It used to be just JavaScript but people started to ship an entire runtime, Bun as an example can be a dependency of a Node.js project, so can headless chrome, if its an entire executable program, should it be in NPM?
Lets gloss over that.. this is the inversion of the problem of global vs local, as the local becomes the new global, the problem isn't solved its moved.

Switcheroo

In devcontainers the global dependency are scoped within the container, this flips the above on its head, if the point was to ship dependencies with your project, but your entire environment is your project, then whats the point in local dependencies anymore?

Yes, I think there is, I can think of a situation where you might want to stay local, even in a container, many developers have not yet taken on devcontainers yet, they should give it a try, but they might not see the benefit until they do try, in that case supporting this use case means writing the project in a traditional local dependency way, which is actually more work in dockerfiles and scripting, no scripting is obviously preferred.

Redundant

So then you are supporting devcontainers and local development, I’ll level with you, I’m on team devcontainers, you should not support both, you need to make a call, choose one and drop support for the other, there is no point in adding overhead to development, but know that devcontainres are showing some real potential, they offer;
a way out of the not on my machine problem,
a way out of on-boarding new developers problem, the what’s your version problem, all while adding your entire dev environment into the project version controlled and shared, centralised and fixable, and are really something you need to consider seriously.

Top comments (0)