npm / npm/cli

[BUG] npm install without a lock file is super slow

Open
#3,703 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug perf Release 7.x
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

npm install using the package.json in
https://gist.githubusercontent.com/Artur-/7b27836372efbee1e3c803af09fa9c6f/raw/714405d5a202b01cbf985d0774cdd26dfc98a562/package.json
takes around 5 minutes on my quite modern Mac

Most time is spent on "idealTree:tmp: sill idealTree buildDeps"

This is when you do not have a lock file but the npm cache is prepopulated with everything needed.

With a lock file, installation takes around 20s

Expected Behavior

Installation time should be dominated by the time it takes to copy dependencies from the cache to the project and running possible postinstall scripts.

For reference, using npm 6

npx npm@6 install

takes around 1 minute without a lock file and 35s with a lock file

Steps To Reproduce
mkdir empty-folder
cd empty-folder
curl https://gist.githubusercontent.com/Artur-/7b27836372efbee1e3c803af09fa9c6f/raw/714405d5a202b01cbf985d0774cdd26dfc98a562/package.json  > package.json
time npm install
Environment
  • OS: macOS Big Sur 11.5.2
  • Node: v16.0.0
  • npm: 7.19.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in an empty folder with the linked package.json and the provided npm install command, then compare it with npm 6 and the lock-file case. Start by investigating the reported "idealTree:tmp: sill idealTree buildDeps" phase. Done means addressing the slowdown while preserving dependency installation and postinstall behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.