I use this package in an internal package I wrote for my org. While executing the pipeline, I ran into an error stating that _stringWidth is not a function in file node_modules/cli-progress/lib/formatter.js at line 57:
constfullMargin=Math.max(0,params.maxWidth-_stringWidth(s)-2);
Upon looking into this file, I noticed that the following import isn't destructured/doesn't key-into the default object
const_stringWidth=require('string-width');
possible workarounds:
(1)
const{default: _stringWidth}=require('string-width');(2)
const_stringWidth=require("string-width").default;Instead, I only changed line 57 as follows:
constfullMargin=Math.max(0,params.maxWidth-_stringWidth.default(s)-2);
Which resolved the error.
Type note:
The required _stringWidth const has an alias of
(alias)const_stringWidth: {(string: string): number;default: typeofstringWidth;}import_stringWidth
Contents of output patch file from running yarn patch-package cli-progress using the patch-package npm package
diff --git a/node_modules/cli-progress/lib/formatter.js b/node_modules/cli-progress/lib/formatter.js
index 8ca662d..c59287a 100644
--- a/node_modules/cli-progress/lib/formatter.js+++ b/node_modules/cli-progress/lib/formatter.js@@ -54,7 +54,7 @@ module.exports = function defaultFormatter(options, params, payload){
});
// calculate available whitespace (2 characters margin of error)
- const fullMargin = Math.max(0, params.maxWidth - _stringWidth(s) -2);+ const fullMargin = Math.max(0, params.maxWidth - _stringWidth.default(s) -2);
const halfMargin = Math.floor(fullMargin / 2);
// distribute available whitespace according to position
I use this package in an internal package I wrote for my org. While executing the pipeline, I ran into an error stating that
_stringWidth is not a functionin filenode_modules/cli-progress/lib/formatter.jsat line 57:Upon looking into this file, I noticed that the following import isn't destructured/doesn't key-into the default object
possible workarounds:
(1)
(2)
Instead, I only changed line 57 as follows:
Which resolved the error.
Type note:
The required
_stringWidthconst has an alias ofContents of output patch file from running
yarn patch-package cli-progressusing thepatch-packagenpm package