n4bb12 / verdaccio-github-oauth-ui

📦🔐 GitHub OAuth plugin for Verdaccio
https://verdaccio.org
MIT License
73 stars 45 forks source link

Docker image fails to load the plugin #129

Closed johanhelsing-attensi closed 3 years ago

johanhelsing-attensi commented 3 years ago

Bug Report

I wanted to use verdaccio with docker-compose, but couldn't load the plugin, so I searched the issues here and found #119 . I tried building the docker image, and that's all fine, but when I start the image using the config.yaml in this repo, it fails to load the plugin.

Versions

this repo 3.0.0 (26b85e4854fc)

In the dockerfile, it just starts from verdaccio/verdaccio:latest I also tried specifying a tag for the verdaccio image:

Expected behavior

verdaccio doesn't complain about the plugin not being found.

Observed behaviour

~/dev/verdaccio-github-oauth-ui master docker build . -t verdaccio-github-image
[+] Building 1.9s (8/8) FINISHED
 => [internal] load build definition from Dockerfile                                                                            0.0s
 => => transferring dockerfile: 176B                                                                                            0.0s
 => [internal] load .dockerignore                                                                                               0.1s
 => => transferring context: 55B                                                                                                0.0s
 => [internal] load metadata for docker.io/verdaccio/verdaccio:latest                                                           1.5s
 => [1/3] FROM docker.io/verdaccio/verdaccio@sha256:5cd19a46453f7217a5e83bba77060fa541d8a218bb4ac233bef72a981ae25b22            0.0s
 => [internal] load build context                                                                                               0.1s
 => => transferring context: 851B                                                                                               0.0s
 => CACHED [2/3] RUN yarn add verdaccio-github-oauth-ui                                                                         0.0s
 => [3/3] COPY config.yaml /verdaccio/conf/config.yaml                                                                          0.1s
 => exporting to image                                                                                                          0.1s
 => => exporting layers                                                                                                         0.1s
 => => writing image sha256:998d3491168e7c7e483a6826a7b4df9944556c4a3722c5b2246e5d0790742327                                    0.0s
 => => naming to docker.io/library/verdaccio-github-image                                                                       0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
~/dev/verdaccio-github-oauth-ui master docker run --rm -it verdaccio-github-image
 warn --- config file  - /verdaccio/conf/config.yaml
(node:8) Warning: deprecate: multiple logger configuration is deprecated, please check the migration guide.
(Use `node --trace-warnings ...` to show where the warning was created)
[github-oauth-ui] Version: verdaccio-github-oauth-ui@3.0.0
 error--- plugin not found. try npm install verdaccio-github-oauth-ui
(node:8) UnhandledPromiseRejectionWarning: Error:
        verdaccio-github-oauth-ui plugin not found. try "npm install verdaccio-github-oauth-ui"
    at /opt/verdaccio/build/lib/plugin-loader.js:110:13
    at Array.map (<anonymous>)
    at loadPlugin (/opt/verdaccio/build/lib/plugin-loader.js:62:37)
    at Auth._loadPlugin (/opt/verdaccio/build/lib/auth.js:56:38)
    at new Auth (/opt/verdaccio/build/lib/auth.js:46:25)
    at defineAPI (/opt/verdaccio/build/api/index.js:43:16)
    at _default (/opt/verdaccio/build/api/index.js:124:10)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:8) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8) [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.

Steps to reproduce

clone this repo

docker build . -t verdaccio-github-image
docker run --rm -it verdaccio-github-image

Additional info

I also tried a hacky way of instlaling plugins in docker that works for the "auth-memory" plugin: https://github.com/verdaccio/verdaccio/issues/1677#issuecomment-828573206 . Unfortunately, that didn't do the trick here, I get slightly different logs then:

FROM verdaccio/verdaccio:5.0.0

USER root

RUN npm install -g --no-bin-links --prefix /tmp/plugins-install verdaccio-github-oauth-ui \
    && mv /tmp/plugins-install/lib/node_modules/* /verdaccio/plugins \
    && chown -R 100001:65533 /verdaccio \
    && rm -rf /tmp/plugins-install

COPY config.yaml /verdaccio/conf/config.yaml

USER verdaccio
 warn --- config file  - /verdaccio/conf/config.yaml
(node:9) Warning: deprecate: multiple logger configuration is deprecated, please check the migration guide.
(Use `node --trace-warnings ...` to show where the warning was created)
 error--- plugin not found. try npm install verdaccio-github-oauth-ui
(node:9) UnhandledPromiseRejectionWarning: Error:
        verdaccio-github-oauth-ui plugin not found. try "npm install verdaccio-github-oauth-ui"
    at /opt/verdaccio/build/lib/plugin-loader.js:110:13
    at Array.map (<anonymous>)
    at loadPlugin (/opt/verdaccio/build/lib/plugin-loader.js:62:37)
    at Auth._loadPlugin (/opt/verdaccio/build/lib/auth.js:56:38)
    at new Auth (/opt/verdaccio/build/lib/auth.js:46:25)
    at defineAPI (/opt/verdaccio/build/api/index.js:43:16)
    at _default (/opt/verdaccio/build/api/index.js:124:10)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:9) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9) [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.

So one shows a line with [github-oauth-ui] Version: verdaccio-github-oauth-ui@3.0.0, but the other doesn't. I don't understand enough npm, yarn plugin loading etc. to debug this further.

n4bb12 commented 3 years ago

It looks like the docker image verdaccio/verdaccio:latest still uses version 4 of verdaccio, so you'll need to use version 2.x of the plugin. Could you verify this?

johanhelsing-attensi commented 3 years ago

It looks like the docker image verdaccio/verdaccio:latest still uses version 4 of verdaccio

@n4bb12 Are you sure a bout that? Maybe you didn't pull first?

$ docker pull verdaccio/verdaccio && docker run --rm verdaccio/verdaccio  /opt/verdaccio/bin/verdaccio --version
Using default tag: latest
latest: Pulling from verdaccio/verdaccio
Digest: sha256:5cd19a46453f7217a5e83bba77060fa541d8a218bb4ac233bef72a981ae25b22
Status: Image is up to date for verdaccio/verdaccio:latest
docker.io/verdaccio/verdaccio:latest
v5.0.4

Thanks for the tip, though, will try v4. Hope it doesn't break the rest of my config 🤞

n4bb12 commented 3 years ago

@n4bb12 Are you sure a bout that? Maybe you didn't pull first?

I'm not sure, I only had a look at the image page where it says "Verdaccio 4". 🤷‍♂️ https://hub.docker.com/r/verdaccio/verdaccio/

Will have a look at what's up with that. Thanks for reporting.

n4bb12 commented 3 years ago

It might also be related to yarn berry which now seems to be used. Maybe this makes it so that plugins are no longer found? Are you able to install other plugins? Specifically, are you able to install other third-party plugins that are NOT shipped with verdaccio?

johanhelsing-attensi commented 3 years ago

I was able to install verdaccio-auth-memory, but only by using the workaround I described.

EDIT: (It's part of the verdaccio project, but not part of the image)

johanhelsing-attensi commented 3 years ago

Verdaccio v4 and github-oauth-ui 2.4.0 seems to still work, though:

FROM verdaccio/verdaccio:4
USER root
RUN yarn add verdaccio-github-oauth-ui@2.4.0
COPY config.yaml /verdaccio/conf/config.yaml
USER verdaccio
~/dev/verdaccio-github-oauth-ui master ~1 docker build . -t verdaccio-github-image && docker run -it verdaccio-github-image
[+] Building 123.3s (8/8) FINISHED
 => [internal] load build definition from Dockerfile                                                                            0.0s
 => => transferring dockerfile: 185B                                                                                            0.0s
 => [internal] load .dockerignore                                                                                               0.2s
 => => transferring context: 34B                                                                                                0.0s
 => [internal] load metadata for docker.io/verdaccio/verdaccio:4                                                                1.3s
 => CACHED [1/3] FROM docker.io/verdaccio/verdaccio:4@sha256:20a33a60f898628d2535f10dfec1a86806b5e9ed029cacaedcc9102a8aab4b37   0.0s
 => [internal] load build context                                                                                               0.1s
 => => transferring context: 33B                                                                                                0.0s
 => [2/3] RUN yarn add verdaccio-github-oauth-ui@2.4.0                                                                        110.5s
 => [3/3] COPY config.yaml /verdaccio/conf/config.yaml                                                                          0.2s
 => exporting to image                                                                                                         10.9s
 => => exporting layers                                                                                                        10.8s
 => => writing image sha256:68cd14d35e0fdd3b3dbf2cbf34a2a0edfa0cd3677b09db8f45aac59e8d3e1453                                    0.0s
 => => naming to docker.io/library/verdaccio-github-image                                                                       0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
 warn --- config file  - /verdaccio/conf/config.yaml
 warn --- Verdaccio started
[github-oauth-ui] Version: verdaccio-github-oauth-ui@2.4.0
[github-oauth-ui] Proxy config: {"HTTP_PROXY":null,"HTTPS_PROXY":null,"NO_PROXY":null}
 warn --- Plugin successfully loaded: verdaccio-github-oauth-ui
 warn --- Plugin successfully loaded: verdaccio-htpasswd
[github-oauth-ui] Proxy config: {"HTTP_PROXY":null,"HTTPS_PROXY":null,"NO_PROXY":null}
 warn --- Plugin successfully loaded: verdaccio-github-oauth-ui
 warn --- http address - http://0.0.0.0:4873/ - verdaccio/4.12.0

I guess maybe plugin loading on docker setups kind of broke with verdaccio v5?

So in a way perhaps it's blocked by https://github.com/verdaccio/verdaccio/issues/1677 ? At least I have no idea what the official way to install a plugin is now... yarn? npm? pnpm? --global, or not?

n4bb12 commented 3 years ago

Thanks for collecting all the info.

n4bb12 commented 3 years ago

What's strange is that it does print this line

[github-oauth-ui] Version: verdaccio-github-oauth-ui@3.0.0

I think I found the reason. When logging the require calls verdaccio makes, and the errors it catches, I get this

{ path: 'verdaccio-github-oauth-ui' }
[github-oauth-ui] Version: verdaccio-github-oauth-ui@3.0.0
{
  err: Error: Cannot find module 'verdaccio/build/lib/utils'
``` ACS@AZEESS MINGW64 /D/Projects/n4bb12/verdaccio-github-oauth-ui yarn test:docker yarn run v1.22.4 $ bash run test-docker [test-docker] docker rm --force verdaccio verdaccio [test-docker] docker build --tag verdaccio . [+] Building 1.8s (10/10) FINISHED => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 32B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 34B 0.0s => [internal] load metadata for docker.io/verdaccio/verdaccio:5 1.4s => [auth] verdaccio/verdaccio:pull token for registry-1.docker.io 0.0s => [internal] load build context 0.2s => => transferring context: 16.08kB 0.2s => [1/4] FROM docker.io/verdaccio/verdaccio:5@sha256:5cd19a46453f7217a5e83bba77060fa541d8a218bb4ac233bef72a981ae25b22 0.0s => CACHED [2/4] RUN yarn add verdaccio-github-oauth-ui@3 0.0s => CACHED [3/4] COPY config.yaml /verdaccio/conf/config.yaml 0.0s => [4/4] COPY node_modules/verdaccio/build/lib/plugin-loader.js build/lib/plugin-loader.js 0.0s => exporting to image 0.1s => => exporting layers 0.0s => => writing image sha256:5614406a885582eb73fa5d1606e1add384194572b75712da55ddc63d4fce6880 0.0s => => naming to docker.io/library/verdaccio 0.0s Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them [test-docker] docker run --publish 4873:4873 --env GITHUB_ORG=n4bb12-oauth-testing --env GITHUB_CLIENT_ID=4fc7e9197f5449f0f170 --env GITHUB_CLIENT_SECRET=670f5d4d13afb9a3fe3423f65227fbd245fca6a9 --name verdaccio verdaccio warn --- config file - /verdaccio/conf/config.yaml (node:9) Warning: deprecate: multiple logger configuration is deprecated, please check the migration guide. (Use `node --trace-warnings ...` to show where the warning was created) { path: '/opt/verdaccio/build/plugins/github-oauth-ui' } { err: Error: Cannot find module '/opt/verdaccio/build/plugins/github-oauth-ui' Require stack: - /opt/verdaccio/build/lib/plugin-loader.js - /opt/verdaccio/build/lib/local-storage.js - /opt/verdaccio/build/lib/storage.js - /opt/verdaccio/build/api/index.js - /opt/verdaccio/build/lib/bootstrap.js - /opt/verdaccio/build/lib/cli/commands/init.js - /opt/verdaccio/build/lib/cli/cli.js - /opt/verdaccio/build/lib/cli.js - /opt/verdaccio/bin/verdaccio at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at tryLoad (/opt/verdaccio/build/lib/plugin-loader.js:26:12) at /opt/verdaccio/build/lib/plugin-loader.js:70:14 at Array.map () at loadPlugin (/opt/verdaccio/build/lib/plugin-loader.js:64:37) at Auth._loadPlugin (/opt/verdaccio/build/lib/auth.js:56:38) at new Auth (/opt/verdaccio/build/lib/auth.js:46:25) { code: 'MODULE_NOT_FOUND', requireStack: [ '/opt/verdaccio/build/lib/plugin-loader.js', '/opt/verdaccio/build/lib/local-storage.js', '/opt/verdaccio/build/lib/storage.js', '/opt/verdaccio/build/api/index.js', '/opt/verdaccio/build/lib/bootstrap.js', '/opt/verdaccio/build/lib/cli/commands/init.js', '/opt/verdaccio/build/lib/cli/cli.js', '/opt/verdaccio/build/lib/cli.js', '/opt/verdaccio/bin/verdaccio' ] } } { plugin: null } { path: '/opt/verdaccio/plugins/github-oauth-ui' } { err: Error: Cannot find module '/opt/verdaccio/plugins/github-oauth-ui' Require stack: - /opt/verdaccio/build/lib/plugin-loader.js - /opt/verdaccio/build/lib/local-storage.js - /opt/verdaccio/build/lib/storage.js - /opt/verdaccio/build/api/index.js - /opt/verdaccio/build/lib/bootstrap.js - /opt/verdaccio/build/lib/cli/commands/init.js - /opt/verdaccio/build/lib/cli/cli.js - /opt/verdaccio/build/lib/cli.js - /opt/verdaccio/bin/verdaccio at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at tryLoad (/opt/verdaccio/build/lib/plugin-loader.js:26:12) at /opt/verdaccio/build/lib/plugin-loader.js:78:16 at Array.map () at loadPlugin (/opt/verdaccio/build/lib/plugin-loader.js:64:37) at Auth._loadPlugin (/opt/verdaccio/build/lib/auth.js:56:38) at new Auth (/opt/verdaccio/build/lib/auth.js:46:25) { code: 'MODULE_NOT_FOUND', requireStack: [ '/opt/verdaccio/build/lib/plugin-loader.js', '/opt/verdaccio/build/lib/local-storage.js', '/opt/verdaccio/build/lib/storage.js', '/opt/verdaccio/build/api/index.js', '/opt/verdaccio/build/lib/bootstrap.js', '/opt/verdaccio/build/lib/cli/commands/init.js', '/opt/verdaccio/build/lib/cli/cli.js', '/opt/verdaccio/build/lib/cli.js', '/opt/verdaccio/bin/verdaccio' ] } } { plugin: null } { path: '/opt/verdaccio/plugins/verdaccio-github-oauth-ui' } { err: Error: Cannot find module '/opt/verdaccio/plugins/verdaccio-github-oauth-ui' Require stack: - /opt/verdaccio/build/lib/plugin-loader.js - /opt/verdaccio/build/lib/local-storage.js - /opt/verdaccio/build/lib/storage.js - /opt/verdaccio/build/api/index.js - /opt/verdaccio/build/lib/bootstrap.js - /opt/verdaccio/build/lib/cli/commands/init.js - /opt/verdaccio/build/lib/cli/cli.js - /opt/verdaccio/build/lib/cli.js - /opt/verdaccio/bin/verdaccio at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at tryLoad (/opt/verdaccio/build/lib/plugin-loader.js:26:12) at /opt/verdaccio/build/lib/plugin-loader.js:82:18 at Array.map () at loadPlugin (/opt/verdaccio/build/lib/plugin-loader.js:64:37) at Auth._loadPlugin (/opt/verdaccio/build/lib/auth.js:56:38) at new Auth (/opt/verdaccio/build/lib/auth.js:46:25) { code: 'MODULE_NOT_FOUND', requireStack: [ '/opt/verdaccio/build/lib/plugin-loader.js', '/opt/verdaccio/build/lib/local-storage.js', '/opt/verdaccio/build/lib/storage.js', '/opt/verdaccio/build/api/index.js', '/opt/verdaccio/build/lib/bootstrap.js', '/opt/verdaccio/build/lib/cli/commands/init.js', '/opt/verdaccio/build/lib/cli/cli.js', '/opt/verdaccio/build/lib/cli.js', '/opt/verdaccio/bin/verdaccio' ] } } { plugin: null } { path: '/opt/verdaccio/plugins/sinopia-github-oauth-ui' } { err: Error: Cannot find module '/opt/verdaccio/plugins/sinopia-github-oauth-ui' Require stack: - /opt/verdaccio/build/lib/plugin-loader.js - /opt/verdaccio/build/lib/local-storage.js - /opt/verdaccio/build/lib/storage.js - /opt/verdaccio/build/api/index.js - /opt/verdaccio/build/lib/bootstrap.js - /opt/verdaccio/build/lib/cli/commands/init.js - /opt/verdaccio/build/lib/cli/cli.js - /opt/verdaccio/build/lib/cli.js - /opt/verdaccio/bin/verdaccio at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at tryLoad (/opt/verdaccio/build/lib/plugin-loader.js:26:12) at /opt/verdaccio/build/lib/plugin-loader.js:86:20 at Array.map () at loadPlugin (/opt/verdaccio/build/lib/plugin-loader.js:64:37) at Auth._loadPlugin (/opt/verdaccio/build/lib/auth.js:56:38) at new Auth (/opt/verdaccio/build/lib/auth.js:46:25) { code: 'MODULE_NOT_FOUND', requireStack: [ '/opt/verdaccio/build/lib/plugin-loader.js', '/opt/verdaccio/build/lib/local-storage.js', '/opt/verdaccio/build/lib/storage.js', '/opt/verdaccio/build/api/index.js', '/opt/verdaccio/build/lib/bootstrap.js', '/opt/verdaccio/build/lib/cli/commands/init.js', '/opt/verdaccio/build/lib/cli/cli.js', '/opt/verdaccio/build/lib/cli.js', '/opt/verdaccio/bin/verdaccio' ] } } { plugin: null } { path: 'verdaccio-github-oauth-ui' } [github-oauth-ui] Version: verdaccio-github-oauth-ui@3.0.0 { err: Error: Cannot find module 'verdaccio/build/lib/utils' Require stack: - /opt/verdaccio/node_modules/verdaccio-github-oauth-ui/dist/server.js - /opt/verdaccio/build/lib/plugin-loader.js - /opt/verdaccio/build/lib/local-storage.js - /opt/verdaccio/build/lib/storage.js - /opt/verdaccio/build/api/index.js - /opt/verdaccio/build/lib/bootstrap.js - /opt/verdaccio/build/lib/cli/commands/init.js - /opt/verdaccio/build/lib/cli/cli.js - /opt/verdaccio/build/lib/cli.js - /opt/verdaccio/bin/verdaccio at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at newRequire (/opt/verdaccio/node_modules/verdaccio-github-oauth-ui/dist/server.js:34:18) at localRequire (/opt/verdaccio/node_modules/verdaccio-github-oauth-ui/dist/server.js:53:14) at Object.parcelRequire.dRsD.../../logger (/opt/verdaccio/node_modules/verdaccio-github-oauth-ui/dist/server.js:623:15) at newRequire (/opt/verdaccio/node_modules/verdaccio-github-oauth-ui/dist/server.js:47:24) at localRequire (/opt/verdaccio/node_modules/verdaccio-github-oauth-ui/dist/server.js:53:14) at Object.parcelRequire.W9VQ../CliFlow (/opt/verdaccio/node_modules/verdaccio-github-oauth-ui/dist/server.js:792:14) { code: 'MODULE_NOT_FOUND', requireStack: [ '/opt/verdaccio/node_modules/verdaccio-github-oauth-ui/dist/server.js', '/opt/verdaccio/build/lib/plugin-loader.js', '/opt/verdaccio/build/lib/local-storage.js', '/opt/verdaccio/build/lib/storage.js', '/opt/verdaccio/build/api/index.js', '/opt/verdaccio/build/lib/bootstrap.js', '/opt/verdaccio/build/lib/cli/commands/init.js', '/opt/verdaccio/build/lib/cli/cli.js', '/opt/verdaccio/build/lib/cli.js', '/opt/verdaccio/bin/verdaccio' ] } } { plugin: null } { path: 'sinopia-github-oauth-ui' } { err: Error: Cannot find module 'sinopia-github-oauth-ui' Require stack: - /opt/verdaccio/build/lib/plugin-loader.js - /opt/verdaccio/build/lib/local-storage.js - /opt/verdaccio/build/lib/storage.js - /opt/verdaccio/build/api/index.js - /opt/verdaccio/build/lib/bootstrap.js - /opt/verdaccio/build/lib/cli/commands/init.js - /opt/verdaccio/build/lib/cli/cli.js - /opt/verdaccio/build/lib/cli.js - /opt/verdaccio/bin/verdaccio at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at tryLoad (/opt/verdaccio/build/lib/plugin-loader.js:26:12) at /opt/verdaccio/build/lib/plugin-loader.js:98:18 at Array.map () at loadPlugin (/opt/verdaccio/build/lib/plugin-loader.js:64:37) at Auth._loadPlugin (/opt/verdaccio/build/lib/auth.js:56:38) at new Auth (/opt/verdaccio/build/lib/auth.js:46:25) { code: 'MODULE_NOT_FOUND', requireStack: [ '/opt/verdaccio/build/lib/plugin-loader.js', '/opt/verdaccio/build/lib/local-storage.js', '/opt/verdaccio/build/lib/storage.js', '/opt/verdaccio/build/api/index.js', '/opt/verdaccio/build/lib/bootstrap.js', '/opt/verdaccio/build/lib/cli/commands/init.js', '/opt/verdaccio/build/lib/cli/cli.js', '/opt/verdaccio/build/lib/cli.js', '/opt/verdaccio/bin/verdaccio' ] } } { plugin: null } { path: 'github-oauth-ui' } { err: Error: Cannot find module 'github-oauth-ui' Require stack: - /opt/verdaccio/build/lib/plugin-loader.js - /opt/verdaccio/build/lib/local-storage.js - /opt/verdaccio/build/lib/storage.js - /opt/verdaccio/build/api/index.js - /opt/verdaccio/build/lib/bootstrap.js - /opt/verdaccio/build/lib/cli/commands/init.js - /opt/verdaccio/build/lib/cli/cli.js - /opt/verdaccio/build/lib/cli.js - /opt/verdaccio/bin/verdaccio at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at tryLoad (/opt/verdaccio/build/lib/plugin-loader.js:26:12) at /opt/verdaccio/build/lib/plugin-loader.js:104:16 at Array.map () at loadPlugin (/opt/verdaccio/build/lib/plugin-loader.js:64:37) at Auth._loadPlugin (/opt/verdaccio/build/lib/auth.js:56:38) at new Auth (/opt/verdaccio/build/lib/auth.js:46:25) { code: 'MODULE_NOT_FOUND', requireStack: [ '/opt/verdaccio/build/lib/plugin-loader.js', '/opt/verdaccio/build/lib/local-storage.js', '/opt/verdaccio/build/lib/storage.js', '/opt/verdaccio/build/api/index.js', '/opt/verdaccio/build/lib/bootstrap.js', '/opt/verdaccio/build/lib/cli/commands/init.js', '/opt/verdaccio/build/lib/cli/cli.js', '/opt/verdaccio/build/lib/cli.js', '/opt/verdaccio/bin/verdaccio' ] } } { plugin: null } error--- plugin not found. try npm install verdaccio-github-oauth-ui (node:9) UnhandledPromiseRejectionWarning: Error: verdaccio-github-oauth-ui plugin not found. try "npm install verdaccio-github-oauth-ui" at /opt/verdaccio/build/lib/plugin-loader.js:120:13 at Array.map () at loadPlugin (/opt/verdaccio/build/lib/plugin-loader.js:64:37) at Auth._loadPlugin (/opt/verdaccio/build/lib/auth.js:56:38) at new Auth (/opt/verdaccio/build/lib/auth.js:46:25) at defineAPI (/opt/verdaccio/build/api/index.js:43:16) at _default (/opt/verdaccio/build/api/index.js:124:10) at processTicksAndRejections (internal/process/task_queues.js:93:5) (node:9) 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(). To termin ate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:9) [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. Done in 5.26s. ```
n4bb12 commented 3 years ago

I think the above import isn't working because in the verdaccio docker image verdaccio is not installed as a dependency but copied to the workdir root. Hence node cannot resolve verdaccio itself.

This works:

FROM node:alpine

RUN yarn add verdaccio@5
RUN yarn add verdaccio-github-oauth-ui@3

COPY config.yaml .

CMD yarn verdaccio --config config.yaml --listen http://0.0.0.0:4873
n4bb12 commented 3 years ago

@juanpicado

I am currently doing import { getPublicUrl } from "verdaccio/build/lib/utils". Unfortunately this doesn't work with using the verdaccoio docker base image.

Do you know if verdaccio/build/lib/utils#getPublicUrl is also available in one of the Verdaccio libraries? Or, what would be the correct approach to re-using verdaccio code?

Thanks in advance for any help & insights 🙏

juanpicado commented 3 years ago

Do you know if verdaccio/build/lib/utils#getPublicUrl is also available in one of the Verdaccio libraries? Or, what would be the correct approach to re-using verdaccio code?

I can expose those methods if you like, here https://github.com/verdaccio/verdaccio/blob/5.x/src/index.ts

would that would work for you?

fyi: In verdaccio 6 (currently master branch) you might use directly eg: @verdaccio/utils-xx so no need to require the whole project, but feedback is welcome.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jantoine1 commented 1 year ago

@n4bb12

I'm using the latest verdaccio@5 and verdaccio-github-oauth-ui@6 and running into this issue. Would the solution suggested above by @juanpicado above solve this, or is there a work around I'm missing?

jantoine1 commented 1 year ago

@n4bb12, @juanpicado,

Can we reopen this issue? It seems that both of you have acknowledged that there is indeed an issue, but stopped short of working out a solution.

I cannot get any version of verdaccio-github-oauth-ui to work with verdaccio@5+, no matter how it's installed. I cannot get the configuration mentioned in https://github.com/n4bb12/verdaccio-github-oauth-ui/issues/129#issuecomment-832860047 as working, to work. Verdaccio finds the plugin and loads, and can be used outside of verdaccio-github-oauth-ui, but as soon as I try to login, I get an error regarding the getPublicUrl() function. I also can't use verdaccio-github-oauth-ui@3+ with verdaccio@4 due to incompatibilities.

n4bb12 commented 1 year ago

@jantoine1 I'm afraid I can't do much with the information you provided. I would suggest you open a new issue and describe your problem in detail.