Npm package under organization (solved)

I am attempting to publish an npm package into a private organization, but am struggling.

Following the gitea instructions I now have a revised .npmrc file using the “npm config set” calls suggested.

One confusing part is the {token} mentioned in the docs. Where does that come from? My assumption was the application token that we can generate, which is what I used.

Another assumption from the docs was that the {owner} can be replaced by the organization code.

The result experienced is always the same

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://mygitdomain.tld/api/packages/myorg/npm/
npm ERR! need auth You need to authorize this machine using `npm adduser`

What am I missing or misunderstanding here?

Of course I figured it out right after posting the question. However, the answer may be good to update the documentation.

It was in the .npmrc file

registry=https://mygitdomain.tld/api/packages/myorg/npm/
//mygitdomain.tld/api/packages/myorg/npm/:_authToken={application_token}
//mygitdomain.tld/api/packages/npm/:_authToken={application_token}

The trick was a second auth line without the username/organization in the path.

1 Like

I have been having this issue but I can’t get it to work with my gitea installation (docker, version 1.21.1)

I create a token with my user (permissions to the packages endpoint) but npm does not authenticate. Am I missing something?

registry=https://gitea.mydomain.com/api/packages/myuser/npm
//gitea.mydomain.com/api/packages/myuser/npm/:_authToken=xxxxx96a2f833805fddff79735905fdec99xxxxx
//gitea.mydomain.com/api/packages/npm/:_authToken=xxxxx96a2f833805fddff79735905fdec99xxxxx
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://gitea.mydomain.com/api/packages/myuser/npm
npm ERR! need auth You need to authorize this machine using `npm adduser`

How about use the command? ref npm Package Registry | Gitea Documentation

I have the same problem that i cannot push packages to the npm repo. But it says that the permission to upload package is not permitted.
I got http 403:
(anonymized)

npm notice Publishing to https://git.gitea.com/api/packages/username/npm/ with tag latest and default access
npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://git.gitea.com/api/packages/username/npm/packagename - no permission to upload this package
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.

Can anybody help? I added repos and tokens as described inside the documentation. Also with allowing anything for the token will not work.

Make sure that your token has write permissions to package.

1 Like