400 bad request when logging/pushing npm package to nexus?
{
...,
"publishConfig": {
"registry": "<linkToNexusRepo>"
}
}
Resolve the issue for me by adding this snipped in my package.json
.
Badr
I am a software development holic. I feel myself above the sky and feel that I am superman whenever I write code. Okay, enough with the fantasy :-D. I did my masters thesis in Software Release Management Proces. Currently I am working as DevOps Engineer. I enjoy problem solving, system design, and optimization. Looking forward to learn more in Big Data and Machine Learning. Hope I can get and offer help here. Thanks for reading :-)
Updated on June 23, 2022Comments
-
Badr almost 2 years
I am trying to use a private
npm
registry for my nodejs projects and I am using nexus for that matter. I keptadmin
user to be used, at least for testing and to guarantee there's no permission issue. However, I can login neither publish usingnpm login --registry <private-registry-address>
andnpm publish --registry <private-registry-address>
receptively. I used several methods, first I manually added entries in.npmrc
file as follows:This one is mentioned in Nexus 3 docs:
➜ echo "email=$NPM_EMAIL" > $HOME/.npmrc ➜ echo "_auth=$(echo -n "$NPM_USER:$NPM_PASS" | openssl base64)" >> $HOME/.npmrc ➜ echo "always-auth=true" >> $HOME/.npmrc
Then I try to publish using
npm publish --registry http://172.17.0.1:8081/repository/npmtest/
, but it just gives me:npm ERR! code E400 npm ERR! 400 Bad Request - PUT http://172.17.0.1:8081/repository/npmtest/mypackage
This one is kind of the official in npm docs:
Here, I log in the repo using the credentials I have as follows:
➜ npm login --registry http://172.17.0.1:8081/repository/npmtest/
and enter my login creds:
Username: admin Password: Email: (this IS public) [email protected]
But unfortunately, it gives me the same exact error:
npm ERR! code E400 npm ERR! 400 Bad Request - PUT http://localhost:8081/repository/npmtest/-/user/org.couchdb.user:admin
I have added
npm Bearer Token Realm
in Nexus as I saw in many discussions and it didn't make a difference as well.I have tried to use another repo
verdaccio
and it worked normally, that's why I am pretty sure this is a nexus issue.Note: I am using all repo managers (Nexus and verdaccio) as docker containers, anyway this should not be an issue.
I am running
npm
version6.10
What could be a solution here for nexus to work?