简体   繁体   中英

Caching packages for npm install

npm install hangs for a long time trying to fetch a file from npm registry https://registry.npmjs.org/-/npm/v1/security/advisories/bulk , is there any way to cache this file to speed up this process? I'd install the security package globally but from the log output, it doesn't show the package name (I'm pasting below part of the log of interest).

[...]
npm timing reify:loadBundles Completed in 0ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 17934ms
npm timing auditReport:getReport Completed in 17945ms
[...]

I'm building a node project on an Azure Pipeline in a private host. When the Job Task to install npm packages runs the Azure Agent most likely kills the process because it's taking too long failing the pipeline.

Here is a blog you can refer to, you can get help from it.

You can use the caching solution from Microsoft DevLabs . Add the task before the npm install. The first run takes longer, because the cache needs to be saved. 在此处输入图像描述

Node modules caching in Azure DevOps will reduce your pipeline run duration when your solution relies on node packages.

For details, you can also refer to this .

To speed up first npm install, as a workaround, we could use yarn install or pnpm install -88% + 80% faster than npm install. For details, please refer to this blog .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM