0

I recently added my node_modules directory to version control per this answer's advice.

(By the way, I'm not necessarily of the opinion that adding node_modules to version control is a good practice, but I'm trying to get a deployment working and I don't have anything else to try right now.)

My problem now is that every command I run is followed by about a five-second pause before I get my command prompt back. I assume that this is because I have an ~700MB node_modules directory.

Is there a way to speed up ZSH or do I just have to live with this slowness if I decide to check in node_modules?

Community
  • 1
  • 1
Jason Swett
  • 43,526
  • 67
  • 220
  • 351

1 Answers1

1

Your question is not clear but what I infer is happening is:

  • You have zsh and/or your zsh plugins configured to include some aspects of git repo status in your prompt
  • thus each time zsh goes to render your prompt, it has to run one or more git commands
  • because your repository is so large, these commands tend to be slow

If this is indeed the case, the first thing you should do is alter your zsh configuration to keep these details out of your prompt. This can be done temporarily just while you are working on this particular project. That might alleviate the biggest pain point without much cost/effort.

Secondly, you could try to make node_modules as small as possible with npm dedupe. Then you could eliminate dev dependencies with npm prune --production so the dev deps could be local files but only the deps necessary for prod would be in git. That might require some clever/verbose configuration in .gitignore but may be workable.

But ultimately deps-in-git is the path to failure for reasons like this. Source Code Management is for Source Code.

Peter Lyons
  • 142,938
  • 30
  • 279
  • 274