verdaccio (private npm)

hoho kim·2021년 12월 3일
0

verdaccio 저장소 구축

  • aws ec2생성

  • nodejs 설치(과정 생략)

  • verdaccio install (https://verdaccio.org/docs/installation/)

  • npm install pm2 -g

  • which verdaccio (설치경로 확인)

  • pm2 start 설치경로 (pm2로 프로세스 관리)

  • pm2 save && pm2 startup (프로세스 저장 후 시작 프로그램 등록)

  • nxgin설치 후 80포트 -> 4873포트 proxy

    server {
        listen 80 default_server;
        access_log /var/log/nginx/verdaccio.log;
        charset utf-8;
    
        location / {
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $host;
          proxy_set_header X-NginX-Proxy true;
          proxy_pass http://localhost:4873;
          proxy_redirect off;
        }
    
    }
  • sudo systemctl restart nginx

  • 브라우저를 통해서 npm web ui 확인

    권한

  • https://hostingcanada.org/htpasswd-generator/ (계정 해쉬 생성)

  • cd ~/verdaccio/ (폴더 이동)

  • htpasswd 파일을 같은 폴더에 생성 후 위 계정 해쉬값을 등록(줄바꿈을 통해서 여러 계정 생성)

  • config.yaml 편집 (@monoverse로 시작되는 이름의 모듈을 권한이 있는사람만 접근 가능하도록 변경)

      packages:
      '@monoverse/*':
        # scoped packages
        access: $authenticated
        publish: $authenticated
        unpublish: $authenticated
        proxy: npmjs
    
      '**':
        # allow all users (including non-authenticated users) to read and
        # publish all packages
        #
        # you can specify usernames/groupnames (depending on your auth plugin)
        # and three keywords: "$all", "$anonymous", "$authenticated"
        access: $all
    
        # allow all known users to publish/publish packages
        # (anyone can register by default, remember?)
        publish: $authenticated
        unpublish: $authenticated
    
        # if package is not available locally, proxy requests to 'npmjs' registry
        proxy: npmjs
  • 유저 등록이 안되게 막기

     auth:
      htpasswd:
        file: ./htpasswd
        # Maximum amount of users allowed to register, defaults to "+inf".
        # You can set this to -1 to disable registration.
        max_users: -1
  • pm2 reload all (verdaccio 재시작)

    모듈 업로드

  • 로그인

     npm adduser --registry http://[ipaddress]/
  • 서버 등록

    npm set registry http://[ipaddress]/
  • publish

      npm publish --registry http://[ipaddress]/
  • unpublish

    npm unpublish [module name] -f

    근데 이 프로그램을 '베르다치오'라고 읽는건가??

profile
재밌는 개발

0개의 댓글