"npm error 405 Method Not Allowed - PUT" with npm-publish

Hi there,

I have been struggling with NPM package publication for a while now and can’t find the solution…

We have a Nexus repos installed in our infra (Sonatype Nexus RepositoryOSS 3.74.0-05) inside which I created an NPM hosted repository. Whenever I try to publish an artifact (using npm-publish) I receive an error 405 with the only additional information that the PUT command is not allowed…

npm notice Publishing to https://nexus.<company_name>.io//repository/<repo_name>/ with tag latest and default access
npm error code E405
npm error 405 Method Not Allowed - PUT https://nexus.<company_name>.io//repository/<repo_name>/@<company_name>%2<package_name>

Authentication does not seem to be the problem here since I instead receive a 401 error if I voluntarily corrupt the token (login:password | openssl base64).

Here is the list of commands I used:

npm config set registry=https://nexus.<company_name>.io/repository/<repo_name>/
npm config set @switstack:registry=https://nexus.<company_name>.io//repository/<repo_name>/
npm config set email=admin@<company_name>.io
npm config set //nexus.<company_name>.io/repository/<repo_name/:_auth=<token>
npm publish

I’m a little bit hopeless. Any help would be much appreciated…

Thanks!

You have //repository in a few locations, probably the first thing to do is remove the duplicates

Hi Matthew,

Thanks a lot for your input. That did the trick! I thought the // was harmless for a minute but it wasn’t.

Thanks again!