From 22cefb151a9a8e2e584c5dce5b93c33ef79ae317 Mon Sep 17 00:00:00 2001 From: MasterCassim Date: Fri, 6 Dec 2019 13:56:29 +0100 Subject: [PATCH] Fixed "publish --force" not correctly publishing Currently "publish --force" does not work correctly when the deployed package is already in the registry. This is a regression from v10 where this worked correctly. The following error is thrown in line 138 of publish.js: TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received :14:23) at upload (C:\Program Files\nodejs\node_modules\npm\lib\publish.js:138:12) at C:\Program Files\nodejs\node_modules\npm\lib\publish.js:156:22 at C:\Program Files\nodejs\node_modules\npm\lib\utils\otplease.js:16:12 at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23) at Function.Promise.attempt.Promise.try (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\method.js:39:29) at otplease (C:\Program Files\nodejs\node_modules\npm\lib\utils\otplease.js:14:16) at C:\Program Files\nodejs\node_modules\npm\lib\publish.js:154:20 at PassThroughHandlerContext.finallyHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\finally.js:56:23) at PassThroughHandlerContext.tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:517:31) at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:574:18) { code: 'ERR_INVALID_ARG_VALUE' } The BB.promisify(require('graceful-fs').readFile) throws an error when used with an input buffer which is used in line 156 of publish.js. Using the file path again (PR) fixes the problem and is the same behavior as in v10. --- lib/publish.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/publish.js b/lib/publish.js index e81fc1a057454..2cbb1121ce0c0 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -150,7 +150,7 @@ function upload (pkg, isRetry, cached, opts) { )).finally(() => { // ignore errors. Use the force. Reach out with your feelings. return otplease(opts, opts => { - return upload(pkg, true, tarball, opts) + return upload(pkg, true, cached, opts) }).catch(() => { // but if it fails again, then report the first error. throw err