简体   繁体   English

npm 安装的缓存包

[英]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? npm install挂起很长时间,试图从 npm 注册表https://registry.npmjs.org/-/npm/v1/以任何方式处理文件来缓存文件/安全/ ? 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).我会在全球范围内安装安全 package,但从日志 output 中,它没有显示 package 名称(我在下面粘贴感兴趣的部分)。

[...]
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.我正在私有主机中的 Azure 管道上构建节点项目。 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.当安装 npm 包的作业任务运行 Azure 代理时,很可能会终止该进程,因为管道失败的时间太长。

Here is a blog you can refer to, you can get help from it.这是一个你可以参考的博客,你可以从中获得帮助。

You can use the caching solution from Microsoft DevLabs .您可以使用Microsoft DevLabs的缓存解决方案。 Add the task before the npm install.在 npm 安装之前添加任务。 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.当您的解决方案依赖于节点包时,Azure DevOps 中的节点模块缓存将减少您的管道运行时间。

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.为了加快第一次 npm 安装,作为一种解决方法,我们可以使用yarn installpnpm install -88% + 80% 比 npm 安装快。 For details, please refer to this blog .有关详细信息,请参阅此博客

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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