Skip to content

Installing package from npm takes a long time #436

@Gikkman

Description

@Gikkman

I noticed earlier today when I cloned an older project I have that running npm install took quite a long time. I drilled down in to why, and it turned out that installing concurrently was the main culprit. Or rather, the date-fns library it has as a dependency. I ran the installation instruction again, and supplied the --timing flag, to get some data:

$ npm i -D --timing concurrently

--- Some logs cut for longevity
npm timing idealTree:buildDeps Completed in 1226ms
npm timing idealTree:fixDepFlags Completed in 1ms
npm timing idealTree Completed in 1305ms
npm timing reify:loadTrees Completed in 1306ms
npm timing reify:diffTrees Completed in 5ms
npm timing reify:retireShallow Completed in 1ms
npm timing reify:createSparse Completed in 346ms
npm timing reify:loadBundles Completed in 0ms
npm timing reifyNode:node_modules/wrap-ansi Completed in 413ms
npm timing reifyNode:node_modules/is-fullwidth-code-point Completed in 417ms
npm timing reifyNode:node_modules/string-width Completed in 417ms
npm timing reifyNode:node_modules/concurrently/node_modules/supports-color Completed in 421ms
npm timing reifyNode:node_modules/concurrently/node_modules/has-flag Completed in 421ms
npm timing reifyNode:node_modules/get-caller-file Completed in 422ms
npm timing reifyNode:node_modules/tree-kill Completed in 422ms
npm timing reifyNode:node_modules/require-directory Completed in 427ms
npm timing reifyNode:node_modules/regenerator-runtime Completed in 429ms
npm timing reifyNode:node_modules/escalade Completed in 430ms
npm timing reifyNode:node_modules/emoji-regex Completed in 434ms
npm timing reifyNode:node_modules/cliui Completed in 434ms
npm timing reifyNode:node_modules/y18n Completed in 436ms
npm timing reifyNode:node_modules/spawn-command Completed in 435ms
npm timing reifyNode:node_modules/yargs-parser Completed in 453ms
npm timing reifyNode:node_modules/rxjs/node_modules/tslib Completed in 463ms
npm timing reifyNode:node_modules/shell-quote Completed in 463ms
npm timing reifyNode:node_modules/concurrently Completed in 524ms
npm timing reifyNode:node_modules/yargs Completed in 537ms
npm timing reifyNode:node_modules/@babel/runtime Completed in 605ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 939ms
npm timing auditReport:getReport Completed in 944ms
npm timing auditReport:init Completed in 0ms
npm timing reify:audit Completed in 944ms
npm timing reifyNode:node_modules/lodash Completed in 939ms
npm timing reifyNode:node_modules/rxjs Completed in 1504ms
npm timing reifyNode:node_modules/date-fns Completed in 35361ms
npm timing reify:unpack Completed in 35363ms
npm timing reify:unretire Completed in 0ms
npm timing build:queue Completed in 2ms
npm timing build:link:node_modules/tree-kill Completed in 21ms
npm timing build:link:node_modules/concurrently Completed in 23ms
npm timing build:link Completed in 23ms
npm timing build:deps Completed in 25ms
npm timing build Completed in 25ms
npm timing reify:build Completed in 25ms
npm timing reify:trash Completed in 0ms
npm timing reify:save Completed in 36ms
npm timing reify Completed in 37106ms

added 23 packages, and audited 309 packages in 37s

Notice how the step to reifyNode:node_modules/date-fns (which I think is unpacking the downloaded library) took a little over 35s, of the total 37s. I've re-ran the same command several times, and the results are pretty consistent.

I am not sure what is causing it to take such a long time, but I found an few old issue here talking about date-fns (#329) and it being imported in its fullness. Maybe that could be the problem here too, since the npm installation cannot tree shake the dependency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions