簡體   English   中英

如何將 npm package 依賴項部署到 gitlab 注冊表?

[英]How to deploy npm package dependencies to gitlab registry?

我在構建環境無法訪問互聯網的環境中工作,並且我的應用程序在構建期間使用 npm 包。 到目前為止,我們已經將 node_modules 復制到源並使用它們進行構建。 我們最近移至 gitlab 高級版並希望使用 gitlab 注冊表來存儲我們的 npm 包。 所以我們的問題是 gitlab 只允許發布注冊表而不是它的依賴項。 但這無濟於事,因為當我們進行 npm 安裝時,它將從 Internet 獲取一些 package 依賴項(registry.npm.org.js)將無法訪問 Internet。

My requirement is i should be able to publish all the dependencies also along with package as tar files in the npm registry itself so that during the build when npm install happens it should download packages from gitlab registry itself.

我的 package.json 看起來像這樣:

{
  "name": "@npm-project/aws-sdk-v3-iam-examples",
  "version": "1.2.0",
  "main": "index.js",
  "repository": "git@github.com/awsdocs/aws-doc-sdk-examples/tree/master/javascriptv3/example_code/iam.git",
  "author": "Brian Murray <brmur@amazon.com>, Alex Forsyth <alex-git@amazon.com>",
  "license": "Apache 2.0",
  "dependencies": {
    "@aws-sdk/client-sqs": "^3.32.0",
    "@aws-sdk/node-http-handler": "^3.32.0",
    "@aws-sdk/types": "^3.32.0",
    "ts-node": "^9.0.0"
  },
  "devDependencies": {
    "@types/node": "^14.0.23",
    "typescript": "^4.0.2"
  },
  "publishConfig": {
  "@npm-project:registry": "https://gitlab.com/api/v4/projects/xxxxx/packages/npm/"
}
}

我希望 @aws-sdk/client-sqs,@aws-sdk/node-http-handler,@aws-sdk/types 包在我的 npm 注冊表本身中可用。

它可能看起來像這樣, 在此處輸入圖像描述

您正在搜索的是鏡像/代理注冊表,例如 Nexus、jFrog 或 Verdaccio。 手動維護所有包將非常乏味。

在 GitLab 文檔中我找不到這樣的功能,它們只支持發布范圍私有包,因此根本無法發布像ts-node這樣的包。 因此,您可以選擇自己設置這樣一個可以自動更新的鏡像/代理注冊表。 特別是 Verdaccio 是開源的,免費且易於設置。 我認為 jFrog+GitLab 也是一種常見的組合,但我認為它是一種付費產品。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM