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

triaged
cli
priority:low

(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.

https://github.com/npm/npm/issues/17818
https://github.com/npm/npm/issues/20742
https://github.com/npm/npm/issues/17450
https://github.com/npm/npm/issues/18380
https://github.com/npm/npm/issues/18897
https://github.com/npm/npm/issues/17997
https://github.com/npm/npm/issues/18985


(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.


Release: npm@6.5.0
Release: npm@6.5.0-next.0
(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.


(Jacob) #7

Should be fixed in NPM 6.5.

Update with.
npm install -g npm


(Zentoaku) #8

EDIT2: For the time being my issues seems to be solved with Node 10.15 and npm 6.5

Same problem exists for me since end of September, tried countless solutions nothing works.
Win 10 Enterprise 1709, node 8.11-15, npm 5-6.
Latest check made couple of minutes ago with node 8.15.0 and npm 6.5.0.

C:\projects\pos-angular>npm i
npm WARN tarball tarball data for @angular/compiler@^7.0.1 (sha512-AvYXtjEJ27Rhv4c27DXNEa58Lit63jdydzbz7VuyFhNU+FwDUK2DC4gZe0nWZsf7HUniJezVRFkECDCZQeSKCQ==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for @progress/kendo-angular-intl@^1.6.0 (sha512-s5p4awEM8hBrmqYFL5O/NLJRbUTaoowzdKVWGNSHHoYSJhbWfCDIEKf+u46EYjDzxu5w0HnijUW+2fqvmRw4YA==) seems to be corrupted. Trying one more time.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
npm WARN enoent ENOENT: no such file or directory, open 'C:\projects\pos-angular\node_modules\@progress\kendo-popup-common\package.json'
npm WARN @jsvs/breadcrumbs@3.0.0 requires a peer of codelyzer@~4.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN @jsvs/globals@3.0.1 requires a peer of @angular/core@^6.1.4 but none is installed. You must install peer dependencies yourself.
npm WARN @jsvs/notification@3.0.0 requires a peer of codelyzer@~4.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN @jsvs/security@3.0.0 requires a peer of codelyzer@~4.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN @jsvs/translation@3.0.0 requires a peer of @ngx-translate/core@^10.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN @ngrx/router-store@6.1.2 requires a peer of @angular/common@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngrx/router-store@6.1.2 requires a peer of @angular/core@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngrx/router-store@6.1.2 requires a peer of @angular/router@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngrx/effects@6.1.2 requires a peer of @angular/core@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngrx/store@6.1.2 requires a peer of @angular/core@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.2.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.2.1 requires a peer of popper.js@^1.14.6 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.4.4 requires a peer of @angular/compiler@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.4.4 requires a peer of @angular/core@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! path C:\projects\pos-angular\node_modules\.staging\@angular\compiler-e666ddeb\fesm2015\compiler.js.map
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\projects\pos-angular\node_modules\.staging\@angular\compiler-e666ddeb\fesm2015\compiler.js.map'
npm ERR!  { Error: EPERM: operation not permitted, unlink 'C:\projects\pos-angular\node_modules\.staging\@angular\compiler-e666ddeb\fesm2015\compiler.js.map'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'C:\projects\pos-angular\node_modules\.staging\@angular\compiler-e666ddeb\fesm2015\compiler.js.map'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path: 'C:\\projects\\pos-angular\\node_modules\\.staging\\@angular\\compiler-e666ddeb\\fesm2015\\compiler.js.map' },
npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink \'C:\\projects\\pos-angular\\node_modules\\.staging\\@angular\\compiler-e666ddeb\\fesm2015\\compiler.js.map\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\\projects\\pos-angular\\node_modules\\.staging\\@angular\\compiler-e666ddeb\\fesm2015\\compiler.js.map',
npm ERR!   parent: 'pos-angular' }
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).

Tried with GIT Bash, CMD, CMD admin, PowerShell. Same issue all the time.

EDIT: My issue is similar but not the same. I’m getting this error when trying to run npm install in project. Doesn’t matter if logged in or not. But for example “npm i -g npm@5” or similar works without issue.