T
T
tamtakoe2018-11-23 15:44:41
Angular
tamtakoe, 2018-11-23 15:44:41

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

1 answer(s)
R
Roman Kuzmenko, 2018-11-23
@tamtakoe

https://medium.com/stackfame/how-to-npm-unistall-u...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question