How to ensure dependency isolation in node project?

181 Views Asked by At

I 'm reading the 12-factor-app manifesto and stumbled upon the concept of dependency isolation here. I'm familiar with the concept from working in Python projects using conda. But how can I achieve the same kind of isolation in a nodeJS application?

I had the case in the past where I had eslint installed globally but not defined in package.json in the project. The CI/CD failed later because of a missing dependancies. So I know how much important this can be.

Of course I can always run my apps inside isolated docker containers, but I feel like this is an overkill for local development specially for small projects.

Is there any way to ensure dependancy isolation in nodejs projects?

2

There are 2 best solutions below

1
baltazar On

I believe yarn.lock (for yarn) serves the purpose. All deps are written down there and you can store in source control

0
Casey On

Actually, the CI/CD pipeline is a great way to make sure your dependencies are all documented.

You could create a pipeline that runs on commits and lets the developer know of any issues before the commit is merged into a main branch.