I am struggling to release the new version of multiple packages from one repository.
I am using semantic-release, with a custom plugin to publish multiple packages from Angular monorepo.
The script creates .npmrc
file in each of the about to be published folders/packages, it even creates ~/.npmrc
, just to be sure.
.npmrc file contains: //registry.npmjs.org/:_authToken=...
One of the recent failed attempts: https://travis-ci.org/klemenoslaj/ng-action-outlet/jobs/522273495
The error:
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
Not sure why this is happening and not super familiar with deploying to the NPM registry but could you try adding npm whoami
to your .travis.yml file to see if you are authenticated properly outside your code?
Hi @dominic, thanks for super fast reply.
I added it just before my build starts and I am getting the exact same error: https://travis-ci.org/klemenoslaj/ng-action-outlet/jobs/522413409
https://travis-ci.org/klemenoslaj/ng-action-outlet/jobs/522273495#L692 says:
npm ERR! need auth You need to authorize this machine using `npm adduser`
From what the log tells us, the token is properly decrypted and written to dist/core/.npmrc
.
I suggest reviewing your tool’s/tools’ documentation to ensure it is set up correctly.
@BanzaiMan, in the reply to @dominic I pasted a link to another build, where I executed npm whoami
in the .travis.yml
file itself.
So…NPM_TOKEN
is the correct one, yet npm still does not recognize the user.
Therefore no tool other than npm and travis itself involved.
funny enough. I replaced my npm publish
command with yarn
and now it works perfectly fine.
Glad to hear you made progress but the mystery remains!
Going back to when you added npm whoami
to your .travis.yml file, do you confirm that the .npmrc
file was created before it was called?
If it helps, here’s a simple config showing how to setup your NPM authentication in a build: https://github.com/cotsog/travis_ci_prod_regular/blob/87947e396950ee6e426238f78a379d227155e7f1/.travis.yml#L5-L6.
And here’s the resulting build: https://travis-ci.org/cotsog/travis_ci_prod_regular/builds/522541592#L455.
Remember also that npm whoami
needs to be called in the same directory where your .npmrc
file resides.
Hope this helps!