简体   繁体   中英

installing a npm package in gitlabci from npm private repo

I have a private npm registry in my hosted Gitlab server In a project I need to do a npm build but I get 404 error when trying to fetch the private package in my gitlabci. The link itself works for me:( I try to add the parameters to npmrc (reg and token) and a lot of other options my debug code looks like this

image: node:16

variables:
  NPM_TOKEN: "TOKEN"
default:
  before_script:
    - apt update && apt upgrade -y
    - apt install -y jq
    - ln -sf python3 /usr/bin/python
    - apt install -y python3-pip
    - curl -Lo ./sops 'https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux'
    - chmod +x ./sops
    - mv ./sops /usr/local/bin/
    - pip3 install awscli
    - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile stg
    - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile stg
    - aws configure set region $AWS_DEFAULT_REGION --profile stg
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - git config --global user.email $GITLAB_USER_EMAIL
    - git config --global user.name $GITLAB_USER_ID
    - git fetch
    - rm -f .npmrc
    - rm -f /root/.npmrc
    - rm -f ~/.npmrc
    - printenv NPM_TOKEN
    - echo '@e-comm:registry=https://<URL>:9500/api/v4/projects/99/packages/npm/' >>  ~/.npmrc
    - npm config set //stupidboy.browzwear.com/api/v4/projects/99/packages/npm/:_authToken ${NPM_TOKEN}


stages:
  - test
  - build
  # - deploy

test:
  stage: test
  script:
    - ls -la
    - sops -d ./api/mongo-atlas.stg.pem.enc > ./factory/mongo-atlas.stg.pem
    # - cp $NPMRC_CS_DATA ./factory/.npmrc
    # - cp $NPMRC_CS_DATA ./.npmrc
    - npm config ls -l
    - npm  --prefix ./factory --verbose install
    - npm --prefix ./factory test

the error


npm verb node v16.17.0
npm verb npm  v8.15.0
npm ERR! code E404
npm ERR! 404 Not Found - GET https://<URL>:9500/api/v4/projects/99/packages/npm/@e-comm%2fcs-client
npm ERR! 404 
npm ERR! 404  '@e-comm/cs-client@1.0.0' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm verb exit 1

Ok for future reference The.npmrc needs to be in the directory of the package not in the root of the git, unless it's where you build. The issue was with the way we published and not with the way we consumed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM