Home > Mobile >  NPM giving 400 when try to login from command line
NPM giving 400 when try to login from command line

Time:12-24

I'm using my companies private npm server. I'm having trouble logging in from command line, getting the following error

npm verb login before first PUT {
npm verb login   _id: 'org.couchdb.user:<username>',
npm verb login   name: '<username>',
npm verb login   password: 'XXXXX',
npm verb login   type: 'user',
npm verb login   roles: [],
npm verb login   date: '2021-12-21T14:28:38.709Z'
npm verb login }
npm http fetch PUT 400 
https://<company>/repository/npm/-/user/org.couchdb.user:<username> 40ms
npm verb adduser before first PUT {
npm verb adduser   _id: 'org.couchdb.user:<username>',
npm verb adduser   name: '<username>',
npm verb adduser   password: 'XXXXX',
npm verb adduser   email: '<email>',
npm verb adduser   type: 'user',
npm verb adduser   roles: [],
npm verb adduser   date: '2021-12-21T14:28:38.753Z'
npm verb adduser }
npm http fetch PUT 400 
https://<company>/repository/npm/-/user/org.couchdb.user:<username> 36ms
npm verb stack Error: 400 Bad Request - PUT 
https://<company>/repository/npm/-/user/org.couchdb.user:<username>
npm verb stack     at /usr/lib/node_modules/npm/node_modules/npm-registry-fetch/check- 
response.js:117:15
npm verb stack     at processTicksAndRejections (internal/process/task_queues.js:97:5)
npm verb statusCode 400
npm verb pkgid org.couchdb.user:<my username>
npm verb cwd /home/<my user>/Downloads
npm verb Linux 4.14.231-173.360.amzn2.x86_64
npm verb argv "/usr/bin/node" "/usr/bin/npm" "login" "--verbose" "-- 
registry=https://<my company>/repository/npm/" "--verbose"
npm verb node v12.22.8
npm verb npm  v6.14.15
npm ERR! code E400
npm ERR! 400 Bad Request - PUT 
https://<company>/repository/npm/-/user/org.couchdb.user:dwsollenberger
npm verb exit [ 1, true ]
npm timing npm Completed in 16102ms

I have already tried blowing away my .npmrc files, though I then replaced them with new ones that set up my public and private certs.

Not sure if it's relevant but when I logged into the webiste it originally would let me login but then complain it "could not find user" when I went to my account details for awhile before finally figuring out who I was.

I've also tried running the same put via postman, but get a 500 error. I know my postman didn't have the password set correctly, since I don't know how npm hashes it, so presumably that's the cause of the 500 error.

I'd really like to be able to login to my NPM if anyone can help :)

CodePudding user response:

It turns out I needed to set my CA as well as my other certs. so I ran

npm config set cafile=<path to ca file>

This worked, though I then got an error about my CA containing a self signed cert. I fixed that with:

npm config set strict-ssl false

Incidentally I was also using yarn and despite yarn supposedly reading from the .npmrc file I had to seperately turn off strict-ssl for yarn to get it to work

yarn config set strict-ssl false
  • Related