npm publish broken for all windows users

help-wanted
cli
triaged
priority:medium
good-first-patch

(Darrell) #1

What I Wanted to Do

Trying to publish an npm package to npmjs using npm publish
More evidence of this problem:
https://github.com/npm/npm/issues/20164
https://github.com/npm/npm/issues/18985

What Happened Instead

When running npm publish on Windows 10, I get the following output:

npm notice
npm notice package: netpack-typescript-compiler@0.0.7
npm notice === Tarball Contents ===
npm notice 516B package.json
npm notice 337B jsconfig.json
npm notice 31.2kB netpack-typescript-compiler-0.0.7.tgz
npm notice 467B README.md
npm notice 10B typings.json
npm notice 7.2kB dist/compilerhost.js
npm notice 6.1kB dist/compilerhost.js.map
npm notice 2.9kB dist/test/compiler.test.js
npm notice 2.2kB dist/test/compiler.test.js.map
npm notice 8.3kB src/compilerhost.ts
npm notice 2.9kB src/test/compiler.test.ts
npm notice 354B src/tsconfig.json
npm notice 226B testFiles/moduleA/classa.ts
npm notice 382B testFiles/moduleB/classb.ts
npm notice 236B testFiles/tsconfig.json
npm notice 6.9kB typings/globals/mocha/index.d.ts
npm notice 384B typings/globals/mocha/typings.json
npm notice 112.7kB typings/globals/node/index.d.ts
npm notice 379B typings/globals/node/typings.json
npm notice 151B typings/index.d.ts
npm notice 17.2kB typings/modules/chai/index.d.ts
npm notice 743B typings/modules/chai/typings.json
npm notice 2.7kB typings/modules/memory-fs/index.d.ts
npm notice 396B typings/modules/memory-fs/typings.json
npm notice === Tarball Details ===
npm notice name: netpack-typescript-compiler
npm notice version: 0.0.7
npm notice package size: 63.1 kB
npm notice unpacked size: 204.8 kB
npm notice shasum: b47724fca0f55e29aaf484e2ffb5063c694e37a7
npm notice integrity: sha512-FzQw9x7BUk2DC[…]rwmpqxj+7IpSg==
npm notice total files: 24
npm notice
npm ERR! path C:\Users\ADMINI~1\AppData\Local\Temp\npm-7604-ceeed59e\tmp\fromDir-cf9ad64a\package.tgz
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink ‘C:\Users\ADMINI~1\AppData\Local\Temp\npm-7604-ceeed59e\tmp\fromDir-cf9ad64a\package.tgz’
npm ERR! { Error: EPERM: operation not permitted, unlink ‘C:\Users\ADMINI~1\AppData\Local\Temp\npm-7604-ceeed59e\tmp\fromDir-cf9ad64a\package.tgz’
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink ‘C:\Users\ADMINI~1\AppData\Local\Temp\npm-7604-ceeed59e\tmp\fromDir-cf9ad64a\package.tgz’
npm ERR! errno: -4048,
npm ERR! code: ‘EPERM’,
npm ERR! syscall: ‘unlink’,
npm ERR! path: ‘C:\Users\ADMINI~1\AppData\Local\Temp\npm-7604-ceeed59e\tmp\fromDir-cf9ad64a\package.tgz’ },
npm ERR! isOperational: true,
npm ERR! stack: ‘Error: EPERM: operation not permitted, unlink ‘C:\Users\ADMINI~1\AppData\Local\Temp\npm-7604-ceeed59e\tmp\fromDir-cf9ad64a\package.tgz’’,
npm ERR! errno: -4048,
npm ERR! code: ‘EPERM’,
npm ERR! syscall: ‘unlink’,
npm ERR! path: ‘C:\Users\ADMINI~1\AppData\Local\Temp\npm-7604-ceeed59e\tmp\fromDir-cf9ad64a\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\Administrator\AppData\Roaming\npm-cache_logs\2018-09-30T11_29_08_311Z-debug.log

Reproduction Steps

  1. Install nodejs version v8.12.0 on Windows 10.
  2. git clone https://github.com/dazinator/NetPack-Typescript.git
  3. CD into the root folder, and from a command prompt run npm publish

Note: I get the same error when running the command prompt as “Administrator”

Details

I have successfully published a version of this package before, a long time ago now though: https://www.npmjs.com/package/netpack-typescript-compiler

Platform Info

$ npm --versions
{ 'netpack-typescript-compiler': '0.0.7',
  npm: '6.4.1',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.32.0',
  node: '8.12.0',
  openssl: '1.0.2p',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.2',
  v8: '6.2.414.66',
  zlib: '1.2.11' }
$ node -p process.platform
win32

(Ben Gubler) #2

I have the exact same problem! Scanning through GitHub, people suggested running npm adduser or npm login: neither of them fixed it.

The error only shows up for me when I use 2FA.

Example: $ npm publish --opt=123456 produces an error,

but when I disable 2FA it works.

I ended up just disabling having 2FA required to publish.


(Kat Marchán) #3

This looks like a race or access bug when clearing out the tmpdir. Most likely, the tarball fd isn’t being closed on time.

I have a vague feeling we got a fix for this at some point with a recent refactor from a contributor, but I don’t remember what it was.

Thanks for the bug report!


(Aaron Miller) #4

I am getting this error I’ve tried all suggestions nothing is working. The package.json file is not in the directory specified by the error, so seems like it’s not written there to begin with or is deleted too soon. I was able to publish the initial version of package, but trying to update fails.

thanks

aaron


(Aaron Miller) #5

I created a new sample library called “sample-libary” (w/out the r by accident) and was NOT able to publish it scoped to my user account, getting the same error as before:

code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink

but when I publish as PUBLIC it WAS successful.


(Johnz86) #6

I still have this issue.
npm --versions

{ 'img-pool-upload': '2.0.6',
  npm: '6.4.1',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.33.0',
  node: '8.15.0',
  openssl: '1.0.2q',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.23.2',
  v8: '6.2.414.75',
  zlib: '1.2.11' }

npm publish

npm notice
npm notice package: img-pool-upload@2.0.6
npm notice === Tarball Contents ===
npm notice 1.1kB  package.json
npm notice 824B   jest.config.json
npm notice 68B    README.md
npm notice 522B   tsconfig.json
npm notice 3.6kB  tslint.json
npm notice 3.0kB  src/blob-upload.ts
npm notice 9.4kB  src/data-uploader.ts
npm notice 318B   src/fetch-api.ts
npm notice 3.6kB  src/file-parser.ts
npm notice 15.8kB src/import-workflow.ts
npm notice 705B   src/index.ts
npm notice 1.3kB  src/interval-checker.ts
npm notice 1.3kB  src/keep-alive.ts
npm notice 107B   src/proxy-api.ts
npm notice 1.2kB  src/proxy.ts
npm notice 2.2kB  src/queued-executor.ts
npm notice 1.2kB  src/upload-model.ts
npm notice 1.6kB  src/upload-service.ts
npm notice 1.2kB  src/utils.ts
npm notice 1.0kB  src/validate/base-validator.ts
npm notice 4.7kB  src/validate/consistency-validator.ts
npm notice 245B   src/validate/index.ts
npm notice 1.7kB  src/validate/mandatory-validator.ts
npm notice 702B   src/validate/utils.ts
npm notice 769B   src/validate/validation-constants.ts
npm notice 580B   src/validate/validation-models.ts
npm notice 1.1kB  src/workflow-api.ts
npm notice === Tarball Details ===
npm notice name:          img-pool-upload
npm notice version:       2.0.6
npm notice package size:  14.3 kB
npm notice unpacked size: 59.9 kB
npm notice shasum:        53d90c9b1261b94dd98a4cf37d15b0157994f4ad
npm notice integrity:     sha512-6CbHroRbFhABB[...]d/l7oEGWNH23A==
npm notice total files:   27
npm notice
npm ERR! path C:\Users\z0034zpz\AppData\Local\Temp\npm-36000-94dad811\tmp\fromDir-345d577c\package.tgz
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\z0034zpz\AppData\Local\Temp\npm-36000-94dad811\tmp\fromDir-345d577c\package.tgz'
npm ERR!  { Error: EPERM: operation not permitted, unlink 'C:\Users\z0034zpz\AppData\Local\Temp\npm-36000-94dad811\tmp\fromDir-345d577c\package.tgz'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'C:\Users\z0034zpz\AppData\Local\Temp\npm-36000-94dad811\tmp\fromDir-345d577c\package.tgz'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path: 'C:\\Users\\z0034zpz\\AppData\\Local\\Temp\\npm-36000-94dad811\\tmp\\fromDir-345d577c\\package.tgz' },
npm ERR!   isOperational: true,
npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink \'C:\\Users\\z0034zpz\\AppData\\Local\\Temp\\npm-36000-94dad811\\tmp\\fromDir-345d577c\\package.tgz\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\\Users\\z0034zpz\\AppData\\Local\\Temp\\npm-36000-94dad811\\tmp\\fromDir-345d577c\\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: