gpt4 book ai didi

tfs - NPM:仅安装丢失 - 如何加快 npm install

转载 作者:行者123 更新时间:2023-12-04 11:49:14 26 4
gpt4 key购买 nike

我的 npm 脚本中有很多开发依赖项。 npm install第一次需要几分钟,没关系。

但由于我正在与 TFS 构建服务器集成,因此只需要 npm install 一次。在那之后, npm install 只是在浪费时间,因为它需要 2-3 分钟来确定软件包已经安装。此外,它似乎总是使用 -g 全局标志重新安装软件包,即使存在也是如此。

如何让它检查包是否存在,如果存在,跳过 npm install?

最佳答案

您可以使用 npm-cache如果您使用 on-premise build agents 作为替代方法用于构建。

It is useful for build processes that run [npm|bower|composer|jspm] install every time as part of their build process. Since dependencies don't change often, this often means slower build times. npm-cache helps alleviate this problem by caching previously installed dependencies on the build machine. npm-cache can be a drop-in replacement for any build script that runs [npm|bower|composer|jspm] install.

How it Works

When you run npm-cache install [npm|bower|jspm|composer], it first looks for package.json, bower.json, or composer.json in the current working directory depending on which dependency manager is requested. It then calculates the MD5 hash of the configuration file and looks for a filed named .tar.gz in the cache directory ($HOME/.package_cache by default). If the file does not exist, npm-cache uses the system's installed dependency manager to install the dependencies. Once the dependencies are installed, npm-cache tars the newly downloaded dependencies and stores them in the cache directory. The next time npm-cache runs and sees the same config file, it will find the tarball in the cache directory and untar the dependencies in the current working directory.



你也可以试试 npm-install-missing .

但是,如果您使用的是 VSTS 托管构建代理,则无法执行此操作,因为每次使用托管构建代理对构建进行排队时,都会为构建分配一个干净的构建代理。这意味着代理上没有安装依赖包。您需要执行完整的 npm 安装。

关于tfs - NPM:仅安装丢失 - 如何加快 npm install,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37145762/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com