Sai Vamsi
Sai Vamsi

Reputation: 141

How to deploy npm package dependencies to gitlab registry?

I am working in a environment where build env doesn't have access to internet and my application uses npm packages during the build. Till now we have copied the node_modules to source and used them to build. We recently moved to gitlab premium and want to use gitlab registry to store our npm packages. So our issue is gitlab allows to publish only the registry and not its dependencies. But that will not help use because when we do npm install it will to get the some package dependencies from internet(registry.npm.org.js) which will fail as it will not have internet access.

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.

My package.json looks like this:

{
  "name": "@npm-project/aws-sdk-v3-iam-examples",
  "version": "1.2.0",
  "main": "index.js",
  "repository": "[email protected]/awsdocs/aws-doc-sdk-examples/tree/master/javascriptv3/example_code/iam.git",
  "author": "Brian Murray <[email protected]>, Alex Forsyth <[email protected]>",
  "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/"
}
}

i want @aws-sdk/client-sqs,@aws-sdk/node-http-handler,@aws-sdk/types packages to be available in my npm registry itself.

it might look something like this, enter image description here

Upvotes: 0

Views: 909

Answers (1)

Lalaluka
Lalaluka

Reputation: 1015

What you are searching for are mirror/proxy Registries like Nexus, jFrog or Verdaccio. Maintaining all your packages manually will be incredibly tedious.

In the GitLab Docs I can't find such a feature, they only support publishing scoped private packages so packages like ts-node could not be published at all. So it might be an option to setup such a mirror/proxy Registry yourself which could update automatically. Especially Verdaccio is OpenSource, free and easy to setup. Also jFrog+GitLab is a common combination I think but I think it's a paid product.

Upvotes: 1

Related Questions