npm / npm/cli

[BUG] Installing a single git dependency takes 30 seconds

Open
#3,841 11 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug 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

When using npm 7 installing a single git dependency takes greater then 30 seconds

$ npm i optoolco/_base#be9c5f7 -S
npm http fetch GET 404 https://codeload.github.com/optoolco/_base/tar.gz/be9c5f727a4d94a95cee547d1cf761f193539806 235ms (cache skip)

changed 1 package in 37s

This is a private git dependency over git+ssh

For some more context, the repository is quite small

$ npm ls --prod --depth 999 | wc -l
75
$ npm ls --depth 999 | wc -l
100

I went into an empty directory and ran the same install command to see how long it takes there.

~/optoolco/foobar
$ npm i optoolco/_base#be9c5f7 -S
npm http fetch GET 200 https://registry.npmjs.org/ini 22ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@optoolco%2ftonic 25ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/node-fetch 23ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/tar 24ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@optoolco%2fcomponents 29ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/chownr 16ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/minipass 16ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/mkdirp 14ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/minizlib 16ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/fs-minipass 18ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/yallist 15ms (cache hit)
npm http fetch GET 404 https://codeload.github.com/optoolco/opkit-node/tar.gz/a79014a348914c5a93a932d69a3609d3c60120d2 305ms (cache skip)
npm http fetch GET 404 https://codeload.github.com/optoolco/_base/tar.gz/be9c5f727a4d94a95cee547d1cf761f193539806 306ms (cache skip)

added 13 packages in 36s

Then I ran a similar command, to install a different version of the git dependency and received

$ npm i optoolco/_base#459cbb1 -S
npm http fetch GET 404 https://codeload.github.com/optoolco/_base/tar.gz/459cbb18b6d3382b7d84fb36a17cc64b8a5e35eb 386ms (cache skip)

changed 1 package in 37s

I'm suprised installing a single git dependency takes 37 seconds.

Expected Behavior

For an install of a single dependency to take less than 5 seconds

Steps To Reproduce
  1. Install a git dependency
  2. Wait a long time.
Environment
  • OS: Linux
  • Node: 14
  • npm: 7.24.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

Start by reproducing the private git dependency install with Node 14, npm 7.24.1, and Linux, comparing the populated and empty directories described in the issue. Trace where the roughly 37-second delay occurs; done means the single dependency installs in under 5 seconds without regressing the documented cases.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.