Answer the question
In order to leave comments, you need to log in
How do you remove unnecessary dependencies from node_modules?
A fairly common task. We have Angular/React/etc. a project and some kind of script to start the web server (It often doesn't make sense to move the server into a separate project) and, of course, package.json with dependencies for all this.
We launched it all locally, checked it, then assembled it (often on some Jenkins server) and, as a result, we have an assembled artifact with a couple of server scripts and a bunch of unnecessary dependencies in node_modules like the same Angular or React, which we have to drag into docker container, on servers, etc.
Our task: after the build, remove all unnecessary dependencies from node_modules.
Who does what?
PS So far I'm pushing everything except server dependencies into devDependencies and after building I run `npm prune --production`. This method works, but it's confusing because web frameworks and libraries are usually considered required dependencies and, for example, I won't be able to deploy developer code for debugging. there is no assembly there, and all the necessary dependencies will be removed. This, of course, can be solved, but in any case it is interesting to know how others solve this problem.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question