bufferoverflow / verdaccio-gitlab

private npm registry (Verdaccio) using gitlab-ce as authentication and authorization provider
MIT License
160 stars 55 forks source link

UncaughtPromiseRejectionWarning: Error: `token` (private-token) or `oauth_token` is mandatory on startup #89

Open jojoxd opened 5 years ago

jojoxd commented 5 years ago

Hi, when starting the service, I get the following error;

Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: warn --- config file  - /opt/npm-repo/config.yaml
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: (node:14116) UnhandledPromiseRejectionWarning: Error: `token` (private-token) or `oauth_token` is mandatory
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at new BaseModel (/opt/verdaccio/node_modules/gitlab/dist/latest/infrastructure/BaseService.js:33:13)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at new Groups (/opt/verdaccio/node_modules/gitlab/dist/latest/services/Groups.js:10:1)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at /opt/verdaccio/node_modules/gitlab/dist/latest/infrastructure/Bundler.js:13:22
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at Array.forEach (<anonymous>)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at new Bundle (/opt/verdaccio/node_modules/gitlab/dist/latest/infrastructure/Bundler.js:12:32)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at /opt/verdaccio/node_modules/verdaccio/build/lib/plugin-loader.js:114:30
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at Array.map (<anonymous>)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at loadPlugin (/opt/verdaccio/node_modules/verdaccio/build/lib/plugin-loader.js:65:37)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at Auth._loadPlugin (/opt/verdaccio/node_modules/verdaccio/build/lib/auth.js:45:39)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at new Auth (/opt/verdaccio/node_modules/verdaccio/build/lib/auth.js:35:25)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at defineAPI (/opt/verdaccio/node_modules/verdaccio/build/api/index.js:60:16)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at /opt/verdaccio/node_modules/verdaccio/build/api/index.js:146:12
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at Generator.next (<anonymous>)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at step (/opt/verdaccio/node_modules/verdaccio/build/api/index.js:53:191)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at /opt/verdaccio/node_modules/verdaccio/build/api/index.js:53:361
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: at processTicksAndRejections (internal/process/task_queues.js:85:5)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: (node:14116) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Aug 13 01:18:27 web.jojoxd.nl verdaccio[14116]: (node:14116) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Node Version: v12.8.0 Yarn Version: 1.17.3 OS: CentOS 7

I am trying to run the service as a systemd service, and have tried running it as the user itself.

these are my configurations:

storage: /opt/npm-repo/storage

listen:
  - /run/verdaccio/verdaccio.sock

auth:
  gitlab:
    url: https://gitlab.jojoxd.nl
    authCache:
      enabled: true
      ttl: 300
    publish: $maintainer

packages:
  '@jojoxd/*':
    access: $all
    publish: $authenticated
    gitlab: true

logs:
  - {type: stdout, format: pretty, level: debug}
[Unit]
Description=Verdaccio Service (Private NPM Registry)

Wants=network-online.target
After=network-online.target
After=nginx.service

[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/opt/verdaccio
RuntimeDirectory=verdaccio

PermissionsStartOnly=true

ExecStart=/opt/verdaccio/bin/verdaccio -c /opt/npm-repo/config.yaml

[Install]
WantedBy=multi-user.target

I have run the yarn install job manually, and am running on the v2.2.0 tag. (master does the same).

The /run/verdaccio/verdaccio.sock is an upstream for nginx, which I have been using successfully with normal verdaccio for a long time.

Am I forgetting a configuration option or is this an actual bug?

jojoxd commented 5 years ago

It seems to only do this when using the clone-way of running verdaccio-gitlab. With a fresh CentOS install, on the same versions as the other server, I got it to work using the following;

mkdir /opt/verdaccio && cd /opt/verdaccio
yarn add verdaccio verdaccio-gitlab

using these steps (and ofcourse setting up the www-data user/group, nginx, systemd unit etc.) I got it to work.