我可以将 artifactory 用作本地 npm 缓存吗?

Can I use artifactory as a local npm cache?

当 jenkins 运行s npm install 命令尝试首先从 artifactory 检索模块时,我如何使用 artifactory 来缓存我的节点模块,如果失败,它会从 internet 检索它?

神器是如何工作的?据我了解,当您 运行 npm install X 时,artifactory 将查看它是否具有 X 模块,如果没有,它会从 npm 注册表中检索它。我说得对吗?

How does artifactory work? From what I understand, when you run npm install X, artifactory will see if it has X module if not it retrieves it from the npm registry. Am I correct?

你是对的。 Artifactory 代理远程 npm 存储库,例如 https://registry.npmjs.org,将您与网络问题隔离开来,提供可重现的构建并通过从本地网络检索依赖项来加速构建。

How do I use artifactory to cache my node modules that way when jenkins runs the npm install command it tries to retrieve the modules from artifactory first, and if it fails it retrieves it from the internet?

请按照the User Manual中的说明进行操作。通常,您会将注册表设置为通过 运行 npm config set registry http://hostname:8081/artifactory/api/npm/npm-repo 解析,其中 npm-repo 将是远程或(甚至更好)虚拟存储库。

另请注意,您无需将故障转移配置为 "the internet",因为 Artifactory(如果配置正确)会公开远程存储库的所有内容,因此您永远不会遇到某些情况在Artifactory中找不到,但可以从Artifactory中配置的远程仓库中解析。