Closed ramadimasatria closed 5 years ago
The error might depends of your nodejs set up. I would describe more about your environment otherwise the author of this plugin won’t be able to help you.
Configuration file also helps.
I use the LTS version of nodejs (v10.13.0) installed with nvm.
As for configuration, I changed the default config file on ~/.config/verdaccio/config.yaml
to match with what described on readme.
storage: ./storage
plugins: ./plugins
web:
# WebUI is enabled as default, if you want disable it, just uncomment this line
# enable: false
title: Verdaccio
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
# scoped packages
access: $authenticated
publish: $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 packages
# (anyone can register by default, remember?)
publish: $authenticated
# if package is not available locally, proxy requests to 'npmjs' registry
proxy: npmjs
auth:
github-oauth-ui:
org: myorgname
middlewares:
audit:
enabled: true
github-oauth-ui:
client-id: myclientid
client-secret: myclientsecret
logs:
- {type: stdout, format: pretty, level: http}
Hi Rama,
I tried it using your config and got the same error using npm
.
Interestingly it worked for me when installing with yarn
.
verdaccio-audit
and verdaccio-htpasswd
are direct dependencies of verdaccio
.
https://github.com/verdaccio/verdaccio/blob/master/package.json#L50
Maybe this is the reason they work, but I'm guessing that any other plugin will also fail to load.
I've inserted a console.log("tryLoad", path)
here:
https://github.com/verdaccio/verdaccio/blob/master/src/lib/plugin-loader.js#L15
Results with npm
:
$ verdaccio --config verdaccio.yaml
warn --- config file - D:\Projects\n4bb12\tmp-verdaccio\verdaccio.yaml
tryLoad D:\Tools\node\node_modules\verdaccio\build\plugins\github-oauth-ui
tryLoad D:\Projects\n4bb12\tmp-verdaccio\plugins\github-oauth-ui
tryLoad D:\Projects\n4bb12\tmp-verdaccio\plugins\verdaccio-github-oauth-ui
tryLoad D:\Projects\n4bb12\tmp-verdaccio\plugins\sinopia-github-oauth-ui
tryLoad verdaccio-github-oauth-ui
tryLoad sinopia-github-oauth-ui
tryLoad github-oauth-ui
error--- plugin not found. try npm install verdaccio-github-oauth-ui
(node:7728) UnhandledPromiseRejectionWarning: Error: "github-oauth-ui" plugin not found
try "npm install verdaccio-github-oauth-ui"
at Object.keys.map.pluginId (D:\Tools\node\node_modules\verdaccio\build\lib\plugin-loader.js:107:13)
at Array.map (<anonymous>)
at loadPlugin (D:\Tools\node\node_modules\verdaccio\build\lib\plugin-loader.js:66:37)
at Auth._loadPlugin (D:\Tools\node\node_modules\verdaccio\build\lib\auth.js:45:39)
at new Auth (D:\Tools\node\node_modules\verdaccio\build\lib\auth.js:35:25)
at defineAPI (D:\Tools\node\node_modules\verdaccio\build\api\index.js:60:16)
at D:\Tools\node\node_modules\verdaccio\build\api\index.js:146:12
at Generator.next (<anonymous>)
at step (D:\Tools\node\node_modules\verdaccio\build\api\index.js:53:191)
at D:\Tools\node\node_modules\verdaccio\build\api\index.js:53:361
(node:7728) 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)
(node:7728) [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.
Results with yarn
:
$ verdaccio --config verdaccio.yaml
warn --- config file - D:\Projects\n4bb12\tmp-verdaccio\verdaccio.yaml
tryLoad C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\plugins\github-oauth-ui
tryLoad D:\Projects\n4bb12\tmp-verdaccio\node_modules\github-oauth-ui
tryLoad D:\Projects\n4bb12\tmp-verdaccio\node_modules\verdaccio-github-oauth-ui
tryLoad D:\Projects\n4bb12\tmp-verdaccio\node_modules\sinopia-github-oauth-ui
tryLoad verdaccio-github-oauth-ui
warn --- Plugin successfully loaded: github-oauth-ui
tryLoad C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\plugins\audit
tryLoad D:\Projects\n4bb12\tmp-verdaccio\node_modules\audit
tryLoad D:\Projects\n4bb12\tmp-verdaccio\node_modules\verdaccio-audit
tryLoad D:\Projects\n4bb12\tmp-verdaccio\node_modules\sinopia-audit
tryLoad verdaccio-audit
warn --- Plugin successfully loaded: audit
tryLoad C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\plugins\github-oauth-ui
tryLoad D:\Projects\n4bb12\tmp-verdaccio\node_modules\github-oauth-ui
tryLoad D:\Projects\n4bb12\tmp-verdaccio\node_modules\verdaccio-github-oauth-ui
tryLoad D:\Projects\n4bb12\tmp-verdaccio\node_modules\sinopia-github-oauth-ui
tryLoad verdaccio-github-oauth-ui
warn --- Plugin successfully loaded: github-oauth-ui
warn --- http address - http://localhost:4873/ - verdaccio/3.8.5
Looks like the directory structure is different when installed with yarn
vs npm
, which probably has an effect on whether they can be require
-ed or not.
Interesting, verdaccio relies on the node algorithm (https://nodejs.org/api/modules.html#loading_from_node_modules_Folders), so there is no rocket science in our side, it should no be distinction over the node package manager tool is being used. The npm
version is also important @ramadimasatria @n4bb12 since might be a bug in their side, which is common time on time.
I can confirm the plugin works when installed with yarn, thanks!
I'm currently using npm v6.4.1 and nvm v0.33.11. Will try using other versions and see if the problem persists.
According to node docs, if I read the algorithm correctly, global node_modules
are not searched by default. Only the node installation folder and some default locations in user home are.
https://nodejs.org/api/modules.html#modules_all_together
Using global node_modules
in this way seems to not be the intended way of handling dependencies. The online sources I've found suggest using a local installation.
You can, however, add your global node_modules
folder to NODE_PATH
and the node algorithm will search it. https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
Does making it global give you any advantage? You could still just use a package.json
.
Do you have the option to containerize it? Then you could extend the verdaccio docker image: https://gist.github.com/n4bb12/523e8347a580f596cbf14d0d791b5927
I think the algorithm implies that we can't load global modules from locally installed module. But if we used globally installed verdaccio
node should be able to load other global modules since they are in the same node_modules
directory. CMIIW.
One thing that interests me is other plugins seems to handle global installation just fine. verdaccio-github-oauth is a good example.
I'm setting up verdaccio for a PoC so I installed it globally for the sake of simplicity. I might use local installation or docker later on when I have clearer direction.
Btw, installing with yarn has solved my problem so you can close this issue if you like :)
OK great, will close it then. Glad you got it to work.
node should be able to load other global modules
Apparently not by default. I tried to point that out with reference to the node docs where the node resolve algorithm is described.
other plugins seems to handle global installation just fine
Plugins don't handle installation. They just get require
-ed by verdaccio. There is nothing I can hook into or anything like that.
Below you can see that verdaccio-github-oauth
doesn't work either.
ACS@AZEESS MINGW64 /D/Projects/__lab/tmp-verdaccio
$ npm i -g verdaccio verdaccio-github-oauth
D:\Tools\node\verdaccio -> D:\Tools\node\node_modules\verdaccio\bin\verdaccio
+ verdaccio-github-oauth@1.1.0
+ verdaccio@3.8.5
added 7 packages from 5 contributors and updated 1 package in 13.832s
$ verdaccio --config verdaccio.yaml
warn --- config file - D:\Projects\__lab\tmp-verdaccio\verdaccio.yaml
error--- plugin not found. try npm install verdaccio-github-oauth
(node:19492) UnhandledPromiseRejectionWarning: Error: "github-oauth" plugin not found
try "npm install verdaccio-github-oauth"
at Object.keys.map.pluginId (C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\lib\plugin-loader.js:106:13) at Array.map (<anonymous>)
at loadPlugin (C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\lib\plugin-loader.js:65:37)
at Auth._loadPlugin (C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\lib\auth.js:45:39) at new Auth (C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\lib\auth.js:35:25)
at defineAPI (C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\api\index.js:60:16) at C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\api\index.js:146:12
at Generator.next (<anonymous>) at step (C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\api\index.js:53:191)
at C:\Users\ACS\AppData\Local\Yarn\Data\global\node_modules\verdaccio\build\api\index.js:53:361(node:19492) 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)
(node:19492) [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.
For my future self googling and finding this issue again:
--global
when installingnpm install verdaccio-github-oauth-ui
from the node_modules verdaccio folder, e.g. /usr/local/lib/node_modules/verdaccio
Bug Report
Versions
Expected behavior
I am planning to setup a verdaccio server in a VM. I installed verdaccio and verdaccio-github-oauth-ui globally using
npm i -g verdaccio verdaccio-github-oauth-ui
.Observed behaviour
The
github-oauth-ui
plugin is not detected when I tried runningverdaccio
Steps to reproduce
verdaccio
Additional context