Unhelpful error message when publishing without logging in "Error: EPERM: operation not permitted, unlink"

cli
priority:low
triaged

(Ben Page) #1

What I Wanted to Do

Publish my npm package. I forgot to run npm login on this computer. But the error message is extremely misleading. Instead of saying that you are not authorized to publish this package, it says “The operation was rejected by your operating system.”

What Happened Instead

npm failed to provide a helpful error message

Reproduction Steps

  1. Don’t login to npm
  2. Try to publish
  3. Receive unhelpful error message that say the problem is local.

Details

npm ERR! path C:\Users\bpage\AppData\Local\Temp\npm-20364-0b1bb4e2\tmp\fromDir-c23c1479\package.tgz
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\bpage\AppData\Local\Temp\npm-20364-0b1bb4e2\tmp\fromDir-c23c1479\package.tgz'
npm ERR!  { [Error: EPERM: operation not permitted, unlink 'C:\Users\bpage\AppData\Local\Temp\npm-20364-0b1bb4e2\tmp\fromDir-c23c1479\package.tgz']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'C:\Users\bpage\AppData\Local\Temp\npm-20364-0b1bb4e2\tmp\fromDir-c23c1479\package.tgz'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path:
npm ERR!       'C:\\Users\\bpage\\AppData\\Local\\Temp\\npm-20364-0b1bb4e2\\tmp\\fromDir-c23c1479\\package.tgz' },
npm ERR!   isOperational: true,
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, unlink \'C:\\Users\\bpage\\AppData\\Local\\Temp\\npm-20364-0b1bb4e2\\tmp\\fromDir-c23c1479\\package.tgz\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path:
npm ERR!    'C:\\Users\\bpage\\AppData\\Local\\Temp\\npm-20364-0b1bb4e2\\tmp\\fromDir-c23c1479\\package.tgz' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\bpage\AppData\Roaming\npm-cache\_logs\2018-08-13T21_33_00_524Z-debug.log

Platform Info

$ npm --versions
    { 'node-test': '1.4.4',
      npm: '6.2.0',
      ares: '1.14.0',
      cldr: '33.1',
      http_parser: '2.8.0',
      icu: '62.1',
      modules: '64',
      napi: '3',
      nghttp2: '1.32.0',
      node: '10.8.0',
      openssl: '1.1.0h',
      tz: '2018e',
      unicode: '11.0',
      uv: '1.22.0',
      v8: '6.7.288.49-node.19',
      zlib: '1.2.11' }
$ node -p process.platform
win32

After I ran npm login this stopped happening. This error message really needs to be fixed. It has been reported many times, but never addressed.








(Kat Marchán) #2

Oh really? This only happens when you’re not logged in? :thinking:

This is definitely a bug, and I see how it might be triggered by not being logged in – as would happen with maybe any other error in the same layer. This might have to do with this section of code here.

Purely speculating, I wonder if what’s going on is that errors might get thrown by the npm-registry-client side of things before the fd to that tmp file is being removed before it closes. Alternatively, something might be wrong with the tmp dir disposer.

Or it might be something super basic and simple, but I have no idea what. If this is just an issue with giving bad error messages when an error really did happen, I feel like that makes it lower priority for me, but if anyone wants to do some sleuthing and track down an awful race condition, please go ahead! I can answer questions here or in PMs if you end up picking it up.


(Jacob) #3

Just to confirm, this still happens with windows 10, node 10.12 and npm 6.4.1. Just for fun I tried an elevated command prompt, that doesn’t help either.


(Jacob) #4

Forgot this isn’t github issues where mentioning the issue in a PR puts a note in the issue, here is a pr that I believe contains a fix for this problem https://github.com/npm/cli/pull/80


(Hardik Viradiya) #5

Yes. This still happens with windows 10, node 10.12 and npm 6.4.1. When will be resolved?


(Luis Linan) #6

I can confirm that the problem still happens on Windows 10, node v8.11.3 and npm 6.4.1.
Please does anybody knows how to solve this? I need to get some work done and I can’t because npm won’t let me install the angular cli or any package for that matter.