Skip to content

Enhance npm command docs

Patrizio Bonzani requested to merge bonzani/gitlab:npm-registry-docs into master

What does this MR do and why?

The npm commands for setting up the package registry authentication are incomplete and lead to an 401 unauthorized error when followed step-by-step. This MR add the two missing npm config commands to always use authentication.

Information about the two config parameters can be found at npm docs strict-ssl and npm docs always-auth

How to set up and validate locally

  1. Enable package registry for your repository and create an npm project.
  2. Add a .gitlab-ci.yml file with the steps documented at https://docs.gitlab.com/ee/user/packages/npm_registry/
    deploy:
      stage: deploy
      script:
        - npm config set registry https://gitlab.example.com/api/v4/projects/<your_project_id>/packages/npm/
        - npm config set -- '//gitlab.example.com/api/v4/projects/<your_project_id>/packages/npm/:_authToken' "<your_token>"
        - npm publish
  3. Run the pipeline and get the following result
    Response status code does not indicate success: 401 (Unauthorized)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Patrizio Bonzani

Merge request reports

Loading