3

I'm trying to publish an npm package to our nexus private registry using this command :

npm publish --registry http://localhost:8081/nexus/content/repositories/npmjs

but I get this error :

npm ERR! path C:\Users\USER~1.MAJ\AppData\Local\Temp\npm-13292-e2329f38\tmp\fromDir-e7e42b8d\package.tgz
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\USER~1.MAJ\AppData\Local\Temp\npm-13292-e2329f38\tmp\fromDir-e7e42b8d\package.tgz'
...
npm ERR! Please try running this command again as root/Administrator.

and this is my npm configuration (.npmrc) :

 registry: 'http://localhost:8081/nexus/content/repositories/npmjs/',
  _auth: 'YWRtaW46YWRtaW4xMjM=',
  'always-auth': true 

How can I solve this ?

Edit :

npm -v: 5.3.0

node -v: v8.8.0

npm config get registry: http://localhost:8081/nexus/content/repositories/npmjs

Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191

2 Answers2

3

Thanks to @DarthHater I figured out the solution, so what I was trying to do is publishing to the proxy repository, which was pointing to the official npm registry, instead of doing that I have to create a private (hosted) repository for my own packages, and then use a group repository to provide all the repos under a single URL, by doing that I had to set the group repository as the default repository (in .npmrc) and the private repository as the publish repository (in package.json), and don't forget to assign an email in the .npmrc (any email) so when publishing it will use settings in the local .npmrc (authentification ...) and not the settings in the home .npmrc.

Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191
1

Are you attempting to publish to the proxy or group URL? I ask because the URL looks like it would be a proxy of npmjs just by naming convention. If so, ensure that the URL you are using is for the private hosted repo.

Also, use Nexus Repository 3 :)

DarthHater
  • 3,222
  • 25
  • 26
  • I want to publish to the proxy, this is my nexus administration ui : https://imgur.com/a/2xMXL – Renaud is Not Bill Gates Oct 30 '17 at 09:29
  • It is not possible to publish to proxies. They act as a mirror of the upstream. You'd want to setup a hosted repo for npmjs, and then create a group to likely consume both the upstream npmjs packages as well as your own internal packages in the hosted repository. – DarthHater Oct 30 '17 at 17:11
  • So I did as you said, I've created a group repository that will provide the private repo and the proxy repo under a single URL, which I will use to download my packages, and for publishing I used the private repo, the publishing now works, but when I try to download something from the group repository I get the error not found for the package I want to download even if it's there in the private repository, the same thing for packages in the proxy repository, it seems like the group repository doesn't point on the proxy repository neither on the private repository. – Renaud is Not Bill Gates Oct 31 '17 at 09:34
  • https://stackoverflow.com/questions/47017300/defining-the-group-repository-for-npm-in-nexus – Renaud is Not Bill Gates Oct 31 '17 at 09:40