33800 Docs

← Retour

Correction authentificator - Token npm GitLab expiré

Date: 16/01/2026 17:05 Status : IMPLEMENTEE Problème: Erreur 401 Unauthorized lors de l'installation des packages @nowhere/* Cause: Token glpat-37Pn9EsCjzhmvbb5-Mw6 dans .npmrc expiré

Diagnostic

Le projet utilise des packages npm privés hébergés sur GitLab :

Le .npmrc actuel contient un token d'accès personnel (PAT) qui a expiré.

Solution proposée

Option 1 : CI_JOB_TOKEN (Recommandé)

Modifier .gitlab-ci.yml pour injecter dynamiquement le token dans chaque job :

# Ajouter dans le job test:
test:
  stage: test
  image: node:20-alpine
  tags:
    - docker
  before_script:
    # Configure npm pour utiliser le registry GitLab avec CI_JOB_TOKEN
    - |
      echo "@nowhere:registry=https://gitlab.33800.nowhere84.com/api/v4/projects/10/packages/npm/" >> .npmrc
      echo "//gitlab.33800.nowhere84.com/api/v4/projects/10/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
      echo "@nowhere:registry=https://gitlab.33800.nowhere84.com/api/v4/projects/13/packages/npm/" >> .npmrc
      echo "//gitlab.33800.nowhere84.com/api/v4/projects/13/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
  script:
    # ... reste du script

Avantages :

Option 2 : Nouveau PAT

Créer un nouveau Personal Access Token avec scope read_api et mettre à jour .npmrc.

Inconvénients :

Actions

  1. Modifier .gitlab-ci.yml pour configurer .npmrc avec CI_JOB_TOKEN dans le job test
  2. Modifier le Dockerfile pour utiliser un ARG NPM_TOKEN pendant le build
  3. Relancer le pipeline

Implémentation

Je vais modifier directement les fichiers sur GitLab via l'API.


Attente validation avant exécution