[BUG] npm ci is slow removing existing node_modules
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
If the node_modules folder contains dependencies and npm ci is ran, npm is astronomically slow at "remove existing node_modules/ before installation". It looks like it looks at the dependency tree and deletes them in the node_modules folder manually.
If the point of ci is for continuous integration and to do a clean install of all dependencies without affecting package-lock.json, why cant a simple rm -r node_modules work? This is what I've been doing to speed it up.
Expected Behavior
I see no point in going through the dependency tree if all contents of node_modules will get replaced anyway. Just nuke the whole node_modules folder
Steps To Reproduce
- In a NPM v7.6.3, Node v12.20.1 environment with a node_modules folder with atleast 10 dependencies
- Run
npm ci - Go to the beach and have a day
Environment
- OS: MacOS 11.4
- Node: 12.20.1
- npm: 7.6.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the slow cleanup during npm ci with npm 7.6.3, Node 12.20.1, and an existing node_modules directory containing at least 10 dependencies. Trace the cleanup path used before installation and compare it with removing the directory directly; done means npm ci cleans the directory without the reported delay while preserving package-lock.json.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100