npm publish has resulted in error "You need to authorize this machine using `npm adduser`" #25

Closed
furixturi opened this Issue Jun 11, 2015 · 29 comments

Comments

Projects
None yet
@furixturi

Hi,

In the 08 Publish chapter I was not able to npm publish against the .npmrc local environment. However it worked when the .npmrc file removed and with a connection to https://www.npmjs.com/. None of the following chapters worked correctly either against this local environment, and all worked well again without the .npmrc file and with a connection to https://www.npmjs.com/.

I once went through the 02 Login chapter smoothly and npm whoami returned the correct info. At this point running npm whoami also results in authentication errors.

Looking at the path that userconfig in .npmrc pointed to (userconfig = /Users/xiaoli.shen/.config/how-to-npm/npmrc), there is no such file or folder named npmrc, which might be the reason for the authentication errors.

I'm using version 2.0.0 of how-to-npm and on Mac OS 10.9.5

My npm-debug.log is as follows:

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'adduser' ]
2 info using npm@2.11.1
3 info using node@v0.12.4
4 verbose adduser before first PUT { _id: 'org.couchdb.user:alabebop',
4 verbose adduser   name: 'alabebop',
4 verbose adduser   password: 'XXXXX',
4 verbose adduser   email: 'alabebop@gmail.com',
4 verbose adduser   type: 'user',
4 verbose adduser   roles: [],
4 verbose adduser   date: '2015-06-11T09:07:53.405Z' }
5 verbose request uri http://localhost:15443/-/user/org.couchdb.user:alabebop
6 verbose request new user, so can't send auth
7 info attempt registry request try #1 at 11:07:53
8 verbose request id 8f19ff7f3662cb4c
9 http request PUT http://localhost:15443/-/user/org.couchdb.user:alabebop
10 info retry will retry, error on last attempt: Error: connect ECONNREFUSED
11 info attempt registry request try #2 at 11:08:03
12 http request PUT http://localhost:15443/-/user/org.couchdb.user:alabebop
13 info retry will retry, error on last attempt: Error: connect ECONNREFUSED
14 info attempt registry request try #3 at 11:09:03
15 http request PUT http://localhost:15443/-/user/org.couchdb.user:alabebop
16 verbose request invalidating /Users/xiaoli.shen/.npm/localhost_15443/-/user/org.couchdb.user_3Aalabebop on PUT
17 verbose adduser back [ { [Error: connect ECONNREFUSED]
17 verbose adduser     code: 'ECONNREFUSED',
17 verbose adduser     errno: 'ECONNREFUSED',
17 verbose adduser     syscall: 'connect' },
17 verbose adduser   undefined,
17 verbose adduser   undefined ]
18 verbose stack Error: connect ECONNREFUSED
18 verbose stack     at exports._errnoException (util.js:746:11)
18 verbose stack     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
19 verbose cwd /Users/xiaoli.shen/projects/nodeschool/how-to-npm
20 error Darwin 13.4.0
21 error argv "node" "/usr/local/bin/npm" "adduser"
22 error node v0.12.4
23 error npm  v2.11.1
24 error code ECONNREFUSED
25 error errno ECONNREFUSED
26 error syscall connect
27 error Error: connect ECONNREFUSED
27 error     at exports._errnoException (util.js:746:11)
27 error     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
27 error  { [Error: connect ECONNREFUSED]
27 error   code: 'ECONNREFUSED',
27 error   errno: 'ECONNREFUSED',
27 error   syscall: 'connect' }
28 error If you are behind a proxy, please make sure that the
28 error 'proxy' config is set properly.  See: 'npm help config'
29 verbose exit [ 1, true ]
@swestcott

This comment has been minimized.

Show comment
Hide comment
@swestcott

swestcott Jun 15, 2015

Ditto, same software versions and same error.

Ditto, same software versions and same error.

@meppsilon

This comment has been minimized.

Show comment
Hide comment
@meppsilon

meppsilon Jul 20, 2015

I'm running into this error as well. Any suggestions on how to bypass it?

I'm running into this error as well. Any suggestions on how to bypass it?

@smirciat

This comment has been minimized.

Show comment
Hide comment
@smirciat

smirciat Jul 21, 2015

Same issue here. It sounds like @alabebop has a workaround, but I am too new to this environment to understand it. Is any further guidance available?

Same issue here. It sounds like @alabebop has a workaround, but I am too new to this environment to understand it. Is any further guidance available?

@AnandWalvekar

This comment has been minimized.

Show comment
Hide comment
@AnandWalvekar

AnandWalvekar Jul 29, 2015

It go resolved!!!

  1. Switch to Login module (by typing "how-to-npm" on command line)
  2. Type "npm adduser" to login
  3. Type "npm whoami" to confirm if logged in
  4. Switch back to the package at which you are getting error(my case it was Publish Again)
  5. Type "npm publish"
  6. Done

It go resolved!!!

  1. Switch to Login module (by typing "how-to-npm" on command line)
  2. Type "npm adduser" to login
  3. Type "npm whoami" to confirm if logged in
  4. Switch back to the package at which you are getting error(my case it was Publish Again)
  5. Type "npm publish"
  6. Done
@devhammer

This comment has been minimized.

Show comment
Hide comment
@devhammer

devhammer Jul 31, 2015

@AnandWalvekar That workaround didn't work for me. Still fails to publish, even when npm whomi correctly returns my username.

Getting the following output:

npm ERR! publish Failed PUT 404
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "node" "C:\\Users\\USERNAME\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "publish"
npm ERR! node v0.12.5
npm ERR! npm  v2.13.3
npm ERR! code E404

npm ERR! 404 missing : @myUser/how-to-npm
npm ERR! 404
npm ERR! 404 '@myUser/how-to-npm' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
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! Please include the following file with any support request:
npm ERR!     C:\Users\USERNAME\Documents\node_code\nodeschool.io\how-to-npm\npm-debug.log

@AnandWalvekar That workaround didn't work for me. Still fails to publish, even when npm whomi correctly returns my username.

Getting the following output:

npm ERR! publish Failed PUT 404
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "node" "C:\\Users\\USERNAME\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "publish"
npm ERR! node v0.12.5
npm ERR! npm  v2.13.3
npm ERR! code E404

npm ERR! 404 missing : @myUser/how-to-npm
npm ERR! 404
npm ERR! 404 '@myUser/how-to-npm' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
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! Please include the following file with any support request:
npm ERR!     C:\Users\USERNAME\Documents\node_code\nodeschool.io\how-to-npm\npm-debug.log
@jmanuel1

This comment has been minimized.

Show comment
Hide comment
@jmanuel1

jmanuel1 Aug 14, 2015

Getting same error as @devhammer, with node v0.10.35 on Windows 10.

Getting same error as @devhammer, with node v0.10.35 on Windows 10.

@quangnd

This comment has been minimized.

Show comment
Hide comment
@quangnd

quangnd Aug 16, 2015

AnandWalvekar's solution worked with me!

quangnd commented Aug 16, 2015

AnandWalvekar's solution worked with me!

@davis3792

This comment has been minimized.

Show comment
Hide comment
@davis3792

davis3792 Aug 21, 2015

The work around fixed it for me as well. Wasted a bunch of time getting there though.

The work around fixed it for me as well. Wasted a bunch of time getting there though.

@su6a12

This comment has been minimized.

Show comment
Hide comment
@su6a12

su6a12 Aug 28, 2015

Solution worked for me as well, thanks @AnandWalvekar

su6a12 commented Aug 28, 2015

Solution worked for me as well, thanks @AnandWalvekar

@seonixx

This comment has been minimized.

Show comment
Hide comment
@seonixx

seonixx Aug 30, 2015

Workaround worked for me. Cheers @AnandWalvekar

seonixx commented Aug 30, 2015

Workaround worked for me. Cheers @AnandWalvekar

@bennythejudge

This comment has been minimized.

Show comment
Hide comment
@bennythejudge

bennythejudge Oct 3, 2015

@AnandWalvekar thanks a lot it worked but I had to bump the version.
Could a skip be provided for this step?

@AnandWalvekar thanks a lot it worked but I had to bump the version.
Could a skip be provided for this step?

@jondcoleman

This comment has been minimized.

Show comment
Hide comment
@jondcoleman

jondcoleman Oct 3, 2015

Also had this error and workaround worked for me.

Also had this error and workaround worked for me.

@aclbros

This comment has been minimized.

Show comment
Hide comment
@aclbros

aclbros Oct 18, 2015

Workaround worked for me. Cheers @AnandWalvekar

aclbros commented Oct 18, 2015

Workaround worked for me. Cheers @AnandWalvekar

@ashleygwilliams

This comment has been minimized.

Show comment
Hide comment
@ashleygwilliams

ashleygwilliams Oct 21, 2015

Contributor

closing in favor of #46. i believe the windows problem is already doc'd in #37

Contributor

ashleygwilliams commented Oct 21, 2015

closing in favor of #46. i believe the windows problem is already doc'd in #37

@agungsantoso

This comment has been minimized.

Show comment
Hide comment
@agungsantoso

agungsantoso Mar 14, 2016

AnandWalvekar's solution worked with me!

AnandWalvekar's solution worked with me!

@sawant

This comment has been minimized.

Show comment
Hide comment
@sawant

sawant Mar 25, 2016

I have documented the issue and solution here #8 (comment) .

sawant commented Mar 25, 2016

I have documented the issue and solution here #8 (comment) .

@piyushdubey

This comment has been minimized.

Show comment
Hide comment
@piyushdubey

piyushdubey Mar 29, 2016

@AnandWalvekar's solution worked for me as well!

@AnandWalvekar's solution worked for me as well!

@lpix

This comment has been minimized.

Show comment
Hide comment
@lpix

lpix Mar 29, 2016

@AnandWalvekar's solution worked for me! I suggest adding this as a tip in the module in case someone has the same issue

lpix commented Mar 29, 2016

@AnandWalvekar's solution worked for me! I suggest adding this as a tip in the module in case someone has the same issue

@VladimirBeauge

This comment has been minimized.

Show comment
Hide comment
@VladimirBeauge

VladimirBeauge Jun 18, 2016

@AnandWalvekar Thanks for the solution

@AnandWalvekar Thanks for the solution

@VladimirBeauge VladimirBeauge referenced this issue in freeCodeCamp/freeCodeCamp Jun 18, 2016

Closed

How-To-NPM Publish Again #8770

@swheatley

This comment has been minimized.

Show comment
Hide comment
@swheatley

swheatley Oct 28, 2016

I had to go through the steps a few times but the work around for the solution mentioned above does work :)

I had to go through the steps a few times but the work around for the solution mentioned above does work :)

@sergiomgaspar

This comment has been minimized.

Show comment
Hide comment
@sergiomgaspar

sergiomgaspar Dec 14, 2016

@AnandWalvekar thx for the WA.. worked like a charm :)

@AnandWalvekar thx for the WA.. worked like a charm :)

@alundiak

This comment has been minimized.

Show comment
Hide comment
@alundiak

alundiak Dec 4, 2017

@AnandWalvekar solution works for me locally. but At the moment I can't figure out why the same flow doesn't work on Jenkins.
If someone has ideas, I will very thankful.

This is cut from my custom .npmrc file created by Jenkins.

; userconfig /home/builder/.jenkins/jobs/FDD test - simple project/workspace@tmp/config3550090785588839693tmp
always-auth = true
registry = "https://my-server.com:8443/repository/my-hosted-npm"
strict-ssl = false

always-auth = true means, that I provided NPM user credentials on jenkins level, and I expected Jenkins pass/substitute creds during npm publish but I can't get why it doens't work..

alundiak commented Dec 4, 2017

@AnandWalvekar solution works for me locally. but At the moment I can't figure out why the same flow doesn't work on Jenkins.
If someone has ideas, I will very thankful.

This is cut from my custom .npmrc file created by Jenkins.

; userconfig /home/builder/.jenkins/jobs/FDD test - simple project/workspace@tmp/config3550090785588839693tmp
always-auth = true
registry = "https://my-server.com:8443/repository/my-hosted-npm"
strict-ssl = false

always-auth = true means, that I provided NPM user credentials on jenkins level, and I expected Jenkins pass/substitute creds during npm publish but I can't get why it doens't work..

@renatoathaydes

This comment has been minimized.

Show comment
Hide comment
@renatoathaydes

renatoathaydes Jan 14, 2018

Does not work!

npm adduser
Username: xxxxxx
Password:
Email: (this IS public) xxxxxx@hotmail.com
Logged in as xxxxx on https://registry.npmjs.org/.
➜  lib1 npm publish
npm ERR! code ENEEDAUTH
npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`

Does not work!

npm adduser
Username: xxxxxx
Password:
Email: (this IS public) xxxxxx@hotmail.com
Logged in as xxxxx on https://registry.npmjs.org/.
➜  lib1 npm publish
npm ERR! code ENEEDAUTH
npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`
@alundiak

This comment has been minimized.

Show comment
Hide comment
@alundiak

alundiak Jan 15, 2018

@renatoathaydes

  1. What OS u have?
  2. what is ur .npmrc content or
  3. what is output of npm config list?

I see, you have https://registry.npmjs.org/ as registry, so I assume npm get registry will show it. have you tried to change to http://registry.npmjs.org/ (http).

  1. strict-ssl = false set?
  2. Are u under/behind the some proxy/vpn?

alundiak commented Jan 15, 2018

@renatoathaydes

  1. What OS u have?
  2. what is ur .npmrc content or
  3. what is output of npm config list?

I see, you have https://registry.npmjs.org/ as registry, so I assume npm get registry will show it. have you tried to change to http://registry.npmjs.org/ (http).

  1. strict-ssl = false set?
  2. Are u under/behind the some proxy/vpn?
@renatoathaydes

This comment has been minimized.

Show comment
Hide comment
@renatoathaydes

renatoathaydes Jan 16, 2018

OS: Linux renato 4.4.0-104-generic #127-Ubuntu SMP Mon Dec 11 12:16:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

//registry.npmjs.org/:_authToken=cef314xxxxxxx
init.author.name=Renato Athaydes
init.author.email=renatoathaydes@xxxx
➜  npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.6.0 node/v9.4.0 linux x64"

; userconfig /home/renato/.npmrc
init.author.email = "renatoathaydes@xxxx"
init.author.name = "Renato Athaydes"

; node bin location = /home/renato/.nvm/versions/node/v9.4.0/bin/node
; cwd = /home/renato/programming/projects/node-lib-mismatch/lib3
; HOME = /home/renato
; "npm config ls -l" to show all defaults.

I am at home, no proxies. No strict-ssl = false that I can see. And I would prefer to not use http.

OS: Linux renato 4.4.0-104-generic #127-Ubuntu SMP Mon Dec 11 12:16:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

//registry.npmjs.org/:_authToken=cef314xxxxxxx
init.author.name=Renato Athaydes
init.author.email=renatoathaydes@xxxx
➜  npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.6.0 node/v9.4.0 linux x64"

; userconfig /home/renato/.npmrc
init.author.email = "renatoathaydes@xxxx"
init.author.name = "Renato Athaydes"

; node bin location = /home/renato/.nvm/versions/node/v9.4.0/bin/node
; cwd = /home/renato/programming/projects/node-lib-mismatch/lib3
; HOME = /home/renato
; "npm config ls -l" to show all defaults.

I am at home, no proxies. No strict-ssl = false that I can see. And I would prefer to not use http.

@yordis

This comment has been minimized.

Show comment
Hide comment
@yordis

yordis Feb 10, 2018

I keep getting the same error even when I successfully login. npm whoam give me the correct user but it keep failing no matter what.

yordis commented Feb 10, 2018

I keep getting the same error even when I successfully login. npm whoam give me the correct user but it keep failing no matter what.

@JMuhire

This comment has been minimized.

Show comment
Hide comment
@JMuhire

JMuhire May 14, 2018

In my ci script, I have resolved this issue using a _auth token and setting up the user email like this :

npm config set _auth $NPM_REGISTRY_TOKEN && npm config set registry $NPM_REGISTRY_URL && npm config set always-auth=true && npm config set email=email@email.com

JMuhire commented May 14, 2018

In my ci script, I have resolved this issue using a _auth token and setting up the user email like this :

npm config set _auth $NPM_REGISTRY_TOKEN && npm config set registry $NPM_REGISTRY_URL && npm config set always-auth=true && npm config set email=email@email.com

@petermetz

This comment has been minimized.

Show comment
Hide comment
@petermetz

petermetz May 24, 2018

My issue was that I had the publishConfig object specified in package.json which defined an invalid URL (some private registry).
Had to set it up like this:

  "publishConfig": {
    "registry": "https://registry.npmjs.org/"
  },

My issue was that I had the publishConfig object specified in package.json which defined an invalid URL (some private registry).
Had to set it up like this:

  "publishConfig": {
    "registry": "https://registry.npmjs.org/"
  },
@zrubing

This comment has been minimized.

Show comment
Hide comment
@zrubing

zrubing Jun 15, 2018

npm whoami is correct
I use sudo npm publish is failure,when i switch back to normal user then it worked

zrubing commented Jun 15, 2018

npm whoami is correct
I use sudo npm publish is failure,when i switch back to normal user then it worked

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