Reputation: 43
My goal is to publish a npm package (private if possible) on the Gitlab Registry.
Here is my files :
Package.json :
{
"name": "@sushislasher/sushislasher-package",
"version": "0.0.1",
"description": "Package for game",
"main": "index.ts",
"repository": "https://gitlab.com/sushislasher/sushislasher-package",
"author": "Gildraen",
"license": "MIT",
"private": false
}
Gitlab-CI.yml :
stages:
- deploy
image: $CI_REGISTRY_IMAGE/docker-in-docker
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
COMPOSE_FILE: "docker-compose.yml:docker-compose.gitlab-ci.yml"
.template-load-gitlab-image: &internal-image
before_script:
- docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
- docker-compose pull js || true
deploy:
<<: *internal-image
stage: deploy
script:
- |
{
echo "@${CI_PROJECT_ROOT_NAMESPACE}:registry=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/"
echo "${CI_API_V4_URL#https?}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}"
} | tee -a app/.npmrc
- make install
- make npm-publish
make install build container, up them and do a yarn install. make npm publish do basically a npm publish. All in container. I'm using node:15.7-alpine
But for now, despite all my tries and research, can't make this work, i have this error :
npm ERR! need auth This command requires you to be logged in.
npm ERR! need auth You need to authorize this machine using `npm adduser`
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-02-03T11_51_48_233Z-debug.log
1
I try to follow gitlab doc.. but i'm kind of stuck right now.. What am i doing wrong ?
Upvotes: 0
Views: 1537
Reputation: 43
I managed to do it. With a lot of try and try, here are the key points.
For me it's https://gitlab.com/gildraen/sushislasher-package so my package.json name is @gildraen/sushislasher-package (though the name seems not important)
So I did it all over again from scratch, with paying more attention to this, and it worked. I really think this was my real mistake: the registry name.
Upvotes: 4