Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

400 bad request when logging/pushing npm package to nexus?

I am trying to use a private npm registry for my nodejs projects and I am using nexus for that matter. I kept admin user to be used, at least for testing and to guarantee there's no permission issue. However, I can login neither publish using npm login --registry <private-registry-address> and npm 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 version 6.10

What could be a solution here for nexus to work?

like image 318
Badr Avatar asked Aug 14 '19 10:08

Badr


1 Answers

{
  ...,
  "publishConfig": {
    "registry": "<linkToNexusRepo>"
  }
}

Resolve the issue for me by adding this snipped in my package.json.

like image 184
Pankaj Gamnani Avatar answered Oct 13 '22 09:10

Pankaj Gamnani