Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E401 error on npm publish to Verdaccio in container #3699

Open
Medvind2140 opened this issue Mar 22, 2023 · 6 comments
Open

E401 error on npm publish to Verdaccio in container #3699

Medvind2140 opened this issue Mar 22, 2023 · 6 comments

Comments

@Medvind2140
Copy link

Medvind2140 commented Mar 22, 2023

ENVIRONMENT
verdaccio version: 5.22.1
node version: 19.8.1
package manager: npm 9.5.1
Container installed on Raspberry PI with Docker-compose

BUG
Get an E401 error when trying to: npm publish --registry hostname:port
See image.

I then tried to do the same on an older Verdaccio version 4.8.1, and there was no problem.

So the problems seems to be with the latest version. It looks like the "/" character is converted to %2f in the PUT request that is initiated with npm publish. Is anyone else having this problem?

On server(Pi):

mkdir verdaccio && cd $_
vim docker-compose.yml 
//see image for config

docker-compose up 

On client(Linux)

mkdir project && cd $_
git init && npm init
vim package.json 
//see image for config

npm adduser --registry host:port
npm login --registry host:port
npm publish --registry host:port

Expected behavior

  • Package published to Verdaccio
  • Instead get 401 error

Screenshot from 2023-03-22 18-07-42

@juanpicado
Copy link
Member

what is on the docker-compose.yml would be helpful

@johanneslosch
Copy link
Contributor

what is on the docker-compose.yml would be helpful

@juanpicado as in the upper part of the screenshot shown

docker-compose.yml

version: '3.1'
services:
  verdaccio:
    image: verdaccio/verdaccio
    container_name: 'verdaccio'
    restart: always
    user: 1000:1000
    networks:
      - node-network
    environment:
      - VERDACCIO_PORT=4873
    ports:
      - '4873:4873'
    volumes:
      - './storage:/verdaccio/storage'
      - './config:/verdaccio/config'
      - './plugins:/verdaccio/plugins'
networks:
  node-network:
    driver: bridge

@Medvind2140 as I was facing the issue, I solved it by logging in with the scope parameter and adding the registry to the package.json (since it should only be exposed to verdaccio in my case), so I could simply run npm publish

@Medvind2140
Copy link
Author

Medvind2140 commented Mar 31, 2023

@johanneslosch @juanpicado Thanks for the reply. Yes I have added the registry to package.json. I cleaned up the .npmrc default files as some authTokens seemed to conflict. So I got past the authentication error, however the package is still not accepted.

If its working in your end, It might be my environment, however I though it was strange it worked on an older version.

These are the logs from both the client console and the verdaccio container:

f@LP5:~/d/t/npm/registry-verdaccio$ npm publish
npm notice
npm notice 📦  @med42/registry-verdaccio@0.0.6
npm notice === Tarball Contents ===
npm notice 18B  README.md
npm notice 321B package.json
npm notice === Tarball Details ===
npm notice name:          @med42/registry-verdaccio
npm notice version:       0.0.6
npm notice filename:      med42-registry-verdaccio-0.0.6.tgz
npm notice package size:  350 B
npm notice unpacked size: 339 B
npm notice shasum:        b75f2a9956f86780486708a8a86bae2283e9c0f3
npm notice integrity:     sha512-sr/M6EKn3yBkB[...]e9NjgtKriHC7A==
npm notice total files:   2
npm notice
npm notice Publishing to http://12.23.98.244:4873 with tag latest and default access
npm ERR! code E404
npm ERR! 404 Not Found - PUT http://12.23.98.244:4873/@med42%2fregistry-verdaccio - no such package available
npm ERR! 404
npm ERR! 404  '@med42/registry-verdaccio@0.0.6' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/f/.npm/_logs/2023-03-31T10_48_07_149Z-debug-0.log

Container log:

info --- auth/allow_action: access granted to: undefined
info --- med43 is allowed publish for @med42/registry-verdaccio
http <-- 200, user: med43(12.23.98.238), req: 'PUT /@med42%2fregistry-verdaccio', bytes: 1519/0
info --- making request: 'GET https://registry.npmjs.org/@med42%2Fregistry-verdaccio'
NotFoundError: no such package available
    at getError (/usr/local/lib/node_modules/verdaccio/node_modules/@verdaccio/core/build/error-utils.js:71:45)
    at Object.getNotFound (/usr/local/lib/node_modules/verdaccio/node_modules/@verdaccio/core/build/error-utils.js:97:10)
    at /usr/local/lib/node_modules/verdaccio/build/lib/local-storage.js:582:45
    at /usr/local/lib/node_modules/verdaccio/node_modules/@verdaccio/local-storage/lib/local-fs.js:190:14
http --- 404, req: 'GET https://registry.npmjs.org/@med42%2Fregistry-verdaccio' (streaming)
http --- 404, req: 'GET https://registry.npmjs.org/@med42%2Fregistry-verdaccio', bytes: 0/21
http <-- 404, user: med43(12.23.98.238), req: 'PUT /@med42%2fregistry-verdaccio', error: no such package available

@qinyang912
Copy link

+1

@noxxxxxxxx
Copy link

noxxxxxxxx commented Feb 18, 2024

Looks like If you use the wrong password to log in, this error will appear, so maybe we should check if the account exist then if the password is correct?

Solved!

npm 9.5.1
node v18.16.0
cat /Users/tamakou/.npmrc

registry=https://npm.myprivatedomain.com

npm login or npm adduser

npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR! npm login
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/tamakou/.npm/_logs/2024-02-18T07_07_24_079Z-debug-0.log

@millsoft
Copy link

millsoft commented Apr 5, 2024

I had this problem locally. Tried a lot of things. The solution for me was the length of the username / password. Before I used a short user/pass and now a longer and it works. Not sure why it works, maybe some encryption algorithm constraint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants