workshopper / how-to-npm

A module to teach you how to module.
https://www.npmjs.com/package/how-to-npm
ISC License
1.12k stars 221 forks source link

Is this repository still being maintained in 2023? #151

Open jswanso opened 1 year ago

jswanso commented 1 year ago

Hello @juanpicado, @watilde, @EmmaRamirez, @ccarruitero, et al.

Is this repository still being maintained in 2023? There is nothing on the ReadMe that says it's deprecated. Also, it is still referenced on nodeschool, but the last checkin was August 20, 2020. If the project is not being maintained it would be helpful to have that noted in the ReadMe. I don't want to invest more time into trying to run this if there are no maintainers.

I can submit an official issue if this is still being maintained, but didn't want to go through all that effort if it is not maintained.

Any suggestions on future intent of this project or needs would be helpful for me to know if I should invest any more time in getting this running. If it was a good training I was hoping to add it to my team's official list of training.

Short summary of my issue is that the local registry doesn't allow me to add a user on a windows machine running npm 9.5.1. Possibly because it can't bootstap a root user. I saw an open issue #150 that seemed related, but I have tried the recommendation without any luck. I also saw this was upgraded to use verdaccio #143 for the local registry back in May/Jun 2020, and I have to imagine that is a very old version which might be why it doesn't run with my npm 9.5.1. I couldn't find any docs/readmes in this repository that readily defined the design and intent of the locally registry setup which makes it difficult to triage this issue on my own without wading through all the code and build process of this package.

Any guidance or referenced material is appreciated.

Thanks!

ccarruitero commented 1 year ago

Hi @jswanso Thanks for using this package and for filling this issue.

The idea behind use a local registry is that you don't have to interact with an external service in order to use this package (it is useful if you do a workshop and don't have access to internet).

When the project started they created a script to emulate npm registry and as you mention around mid 2020 we changed it to use verdaccio.

Until I understand you, you are having same problem as #150, right? If you have a trace or some useful information about the error please add it in the same issue to get all centralized in the same place. I'll try to find some time this week to debug the error.

In the meantime I will suggest you to skip the "Login" challenge and try other ones.

juanpicado commented 1 year ago

. I also saw this was upgraded to use verdaccio https://github.com/workshopper/how-to-npm/pull/143 for the local registry back in May/Jun 2020, and I have to imagine that is a very old version which might be why it doesn't run with my npm 9.5.1.

Hi folks, I'd love to help upgrading verdaccio and ensure works fine in all npm versions. Btw, after npm@9.5.0 has introduced a fallback login which should works fine by default.

Anyhow, :) I have no enough rights to give some love to this repo but if I'd get some, I'll be happy yo review PRs.

jswanso commented 1 year ago

I am working on reproducing the issue with detailed logs. Right now I am getting ECONNREFUSED, but guessing that is because my registry isn't starting up for some reason. I have reset the registry a couple times trying to troubleshoot the issue so maybe I locked a port or something. I am hoping a reboot will fix my issue.

I'll keep you posted.

BTW: I pulled down the latest verdaccio and was able to add a user to it locally without any problems.

jswanso commented 1 year ago

Thanks @ccarruitero and @juanpicado for responding and willing to take a look at this!

I was really pleased when working through the exercise to learn you used a local registry to create a sandbox for running these labs. I don't have an npmjs.com account and didn't want to create one just to use this lab.

Here is a detailed rundown of my setup.

For full disclosure I installed this npm package locally instead of globally and then use npx to run the commands. I've never had an issue with this in other projects and I assume this isn't the issue.

After installing the "how-to-npm" package, I ran into multiple issues, but have been able to work through most of them so far by installing missing/outdated packages. Here is what my package.json file looks like for the missing dependencies.

File Content for package.json

``` { "dependencies": { "concat-stream": "^2.0.0", "how-to-npm": "^2.5.1", "which": "^3.0.1", "workshopper-adventure": "^7.0.0" } } ```

Step 2 "02 login" is where I have the issue. I've created a sub directory called "workdir" that is my working directory for running the "02 Login" commands. After running npm init -y in the "workdir" folder it has two files.

Folder Content for workdir

- .npmrc - package.json

File Content for .npmrc

``` registry = http://localhost:15443/ userconfig = C:\Users\\.config\how-to-npm\npmrc ```

File Content for package.json

``` { "name": "workdir", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" } ```

I ran both npm adduser and npm adduser --auth-type=legacy which both failed with the error "No credentials to set." Here is the detailed log message from the second command, but really the error message is the same from either command.

File Content for npm log

``` 0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js 1 info using npm@9.5.1 2 info using node@v18.16.0 3 timing npm:load:whichnode Completed in 2ms 4 timing config:load:defaults Completed in 3ms 5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 2ms 6 timing config:load:builtin Completed in 3ms 7 timing config:load:cli Completed in 2ms 8 timing config:load:env Completed in 0ms 9 timing config:load:file:c:\gittrain\nodeschool-npm2\workdir\.npmrc Completed in 1ms 10 timing config:load:project Completed in 6ms 11 timing config:load:file:C:\Users\\.config\how-to-npm\npmrc Completed in 0ms 12 timing config:load:user Completed in 0ms 13 timing config:load:file:C:\Users\\AppData\Roaming\npm\etc\npmrc Completed in 1ms 14 timing config:load:global Completed in 2ms 15 timing config:load:setEnvs Completed in 1ms 16 timing config:load Completed in 19ms 17 timing npm:load:configload Completed in 19ms 18 timing npm:load:mkdirpcache Completed in 1ms 19 timing npm:load:mkdirplogs Completed in 1ms 20 verbose title npm adduser 21 verbose argv "adduser" "--auth-type" "legacy" 22 timing npm:load:setTitle Completed in 2ms 23 timing config:load:flatten Completed in 5ms 24 timing npm:load:display Completed in 5ms 25 verbose logfile logs-max:10 dir:C:\Users\\AppData\Local\npm-cache\_logs\2023-05-09T21_52_53_138Z- 26 verbose logfile C:\Users\\AppData\Local\npm-cache\_logs\2023-05-09T21_52_53_138Z-debug-0.log 27 timing npm:load:logFile Completed in 9ms 28 timing npm:load:timers Completed in 0ms 29 timing npm:load:configScope Completed in 0ms 30 timing npm:load Completed in 39ms 31 notice Log in on http://localhost:15443/ 32 silly logfile start cleaning logs, removing 2 files 33 silly logfile done cleaning log files 34 verbose adduser before first PUT { 34 verbose adduser _id: 'org.couchdb.user:justin', 34 verbose adduser name: 'justin', 34 verbose adduser password: 'XXXXX', 34 verbose adduser email: 'j@myemail.com', 34 verbose adduser type: 'user', 34 verbose adduser roles: [], 34 verbose adduser date: '2023-05-09T21:53:13.476Z' 34 verbose adduser } 35 http fetch PUT 201 http://localhost:15443/-/user/org.couchdb.user:justin 28ms 36 info adduser Logged in on http://localhost:15443/. 37 timing command:adduser Completed in 20303ms 38 verbose stack Error: No credentials to set. 38 verbose stack at Config.setCredentialsByURI (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\config\lib\index.js:806:13) 38 verbose stack at AddUser.exec (C:\Program Files\nodejs\node_modules\npm\lib\commands\adduser.js:40:21) 38 verbose stack at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli.js:134:5) 39 verbose cwd c:\gittrain\nodeschool-npm2\workdir 40 verbose Windows_NT 10.0.19042 41 verbose node v18.16.0 42 verbose npm v9.5.1 43 error No credentials to set. 44 verbose exit 1 45 timing npm Completed in 20376ms 46 verbose code 1 47 error A complete log of this run can be found in: 47 error C:\Users\\AppData\Local\npm-cache\_logs\2023-05-09T21_52_53_138Z-debug-0.log ```

As seen in the detailed log it is failing on the HTTP put to local host with "No credentials to set". In a separate test I pulled down the "verdaccio" package to run locally just to see if my npm adduser command would get a similar issue, but it worked just fine. Of course, I was running the latest version verdaccio.

Other contextual detail.

npm version

``` { workdir: '1.0.0', npm: '9.5.1', node: '18.16.0', acorn: '8.8.2', ada: '1.0.4', ares: '1.19.0', brotli: '1.0.9', cldr: '42.0', icu: '72.1', llhttp: '6.0.10', modules: '108', napi: '8', nghttp2: '1.52.0', nghttp3: '0.7.0', ngtcp2: '0.8.1', openssl: '3.0.8+quic', simdutf: '3.2.2', tz: '2022g', undici: '5.21.0', unicode: '15.0', uv: '1.44.2', uvwasi: '0.0.15', v8: '10.2.154.26-node.26', zlib: '1.2.13' } ```

Windows Machine Info

- OS Name: Microsoft Windows 10 Pro - OS Version: 10.0.19042 N/A Build 19042 - OS Manufacturer: Microsoft Corporation

I've done a little more debugging locally on the code to see if I could spot the issue, but I think I am missing some context on the setup of these workshops. I didn't find any additional architecture and getting started documentation in this repository to go further into debugging.

Any help is appreciated. If you have any additional resources you could point me at to help fill in the gaps that would also be great.

jswanso commented 1 year ago

Hello @juanpicado and @ccarruitero

I traced through the npm CLI code to see why I get a "No credentials to set" error. Here are my findings.

Summary

The locally hosted Verdaccio registry used in the latest how-to-npm package doesn't return a token when npm adduser command is called and subsequently errors out. I am use npm version 9.5.1.

Details

The CLI npm adduser command calls setCredentialsByURI method passing in new credentials (newCreds). All the parameters passed into the setCredentialsByURI method are undefined other than the URI parameter which, as expected, points to the localhost (i.e., http://localhost:15443/). The setCredentialsByURI method is what throws the No credentials to set error that is reported in my prior log.

Walking backwards in the code I see that the auth.adduser method returns the newCreds variable which consists of { token: undefined }.

Stepping into the auth.js adduser method I see the profile.adduserCouch method called with the command line username, email, and password that I supplied in the CLI when prompted.

The adduserCouch method looks like it does a HTTP PUT to the local registry which based on the logs is successful with a HTTP Status Code of 201. The returned results res consists of { ok: 'created', username: 'justin' }, but it doesn't have a token returned. Subsequently the auth.js adduser method returns the undefined token to the calling adduser method.

Assuming that the npm CLI code is correct, the issue seems to be with the locally hosted repository not returning a token. I don't know what the expectations are of this registry, and I hope someone can provide the answer.

For comparison, when I run the latest verdaccio locally my npm adduser works fine and I see the returned payload has a provided token.

Verdaccio returned payload example: { ok: "user 'user1' created", token: 'VkPPcaSLZxmz+bMm822Qyw==', username: 'user1' }

Follow-up

I know @ccarruitero you suggested that I skip # 02, but I fear that doing so is only going to get me so far before I run into this registry issue again. I am hoping the detailed write above will help you in triaging this issue. I am not sure there is much more I can do to help on this without having more background on the design of this workshop.

Further guidance is appreciated.

friari commented 1 month ago

Hi @jswanso did you ever get anywhere with this? I'm having the same issue over a year later.

Hello @juanpicado and @ccarruitero

I traced through the npm CLI code to see why I get a "No credentials to set" error. Here are my findings.

Summary

The locally hosted Verdaccio registry used in the latest how-to-npm package doesn't return a token when npm adduser command is called and subsequently errors out. I am use npm version 9.5.1.

Details

The CLI npm adduser command calls setCredentialsByURI method passing in new credentials (newCreds). All the parameters passed into the setCredentialsByURI method are undefined other than the URI parameter which, as expected, points to the localhost (i.e., http://localhost:15443/). The setCredentialsByURI method is what throws the No credentials to set error that is reported in my prior log.

Walking backwards in the code I see that the auth.adduser method returns the newCreds variable which consists of { token: undefined }.

Stepping into the auth.js adduser method I see the profile.adduserCouch method called with the command line username, email, and password that I supplied in the CLI when prompted.

The adduserCouch method looks like it does a HTTP PUT to the local registry which based on the logs is successful with a HTTP Status Code of 201. The returned results res consists of { ok: 'created', username: 'justin' }, but it doesn't have a token returned. Subsequently the auth.js adduser method returns the undefined token to the calling adduser method.

Assuming that the npm CLI code is correct, the issue seems to be with the locally hosted repository not returning a token. I don't know what the expectations are of this registry, and I hope someone can provide the answer.

For comparison, when I run the latest verdaccio locally my npm adduser works fine and I see the returned payload has a provided token.

Verdaccio returned payload example: { ok: "user 'user1' created", token: 'VkPPcaSLZxmz+bMm822Qyw==', username: 'user1' }

Follow-up

I know @ccarruitero you suggested that I skip # 02, but I fear that doing so is only going to get me so far before I run into this registry issue again. I am hoping the detailed write above will help you in triaging this issue. I am not sure there is much more I can do to help on this without having more background on the design of this workshop.

Further guidance is appreciated.