Open svitovyda opened 1 year ago
@svitovyda how did you fix this? I am having the same issue.
The temporary solution is to keep deleting the yarn.lock every time before yarn install.
Hi, is this still an issue? My builds break the same way @svitovyda mentioned. The workaround @sidiqmd provided is working, but quite annoying.
I can confirm that adding the following to package.json will resolve the issue:
"resolutions": {
"string-width": "4.2.3"
}
but would be great if this would get fixed!
@svitovyda how did you fix this? I am having the same issue.
The temporary solution is to keep deleting the yarn.lock every time before yarn install.
Worked for me 👌
I can confirm that adding the following to package.json will resolve the issue:
"resolutions": { "string-width": "4.2.3" }
but would be great if this would get fixed!
Worked for me 👌
I am using bcrypt
in my project. After upgrading my install fails:
error /workspaces/api/node_modules/bcrypt: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /workspaces/api/node_modules/bcrypt
Output:
/workspaces/api/node_modules/wide-align/align.js:2
var stringWidth = require('string-width')
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /workspaces/api/node_modules/string-width/index.js from /workspaces/api/node_modules/wide-align/align.js not supported.
Instead change the require of index.js in /workspaces/api/node_modules/wide-align/align.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/workspaces/api/node_modules/wide-align/align.js:2:19) {
code: 'ERR_REQUIRE_ESM'
}
Using the package.json resolutions
trick mentioned by others fixed it for the time being.
I can confirm that adding the following to package.json will resolve the issue:
"resolutions": { "string-width": "4.2.3" }
but would be great if this would get fixed!
Where in the package.json are you adding it
@TabotCharlesBessong, you can see a lot of examples on GitHub.
Be aware, that resolutions
is a yarn
feature – this mechanism also exists for npm
via overrides
@TabotCharlesBessong You must remove node_modules, yarn.lock and package-lock.json before running yarn or npm install
If this project does require string-width < 5 for it to work, due to CommonJS vs ESM, could we not prevent transitive dependency issues with other packages by changing package.json to something like:
"dependencies": {
"string-width-cjs": "npm:string-width@^1.0.2 || 2 || 3 || 4"
}
And then in the code:
var stringWidth = require('string-width-cjs')
I'm kinda new to all this CommonJS/ESM and package resolution issues though so maybe it doesn't work.
Hello all,
I found a solution and would like to share how to resolve it:
yarn why string-width
to find the library that uses it as a dependency.node_modules
, and then run yarn install
to verify it works.yarn upgrade lib@version
to upgrade only this library.It should work.
Happy coding!
2024-06-03
I can confirm that adding the following to package.json will resolve the issue:
"resolutions": { "string-width": "4.2.3" }
but would be great if this would get fixed!
Where in the package.json are you adding it
anywhere
I can confirm that adding the following to package.json will resolve the issue:
"resolutions": { "string-width": "4.2.3" }
but would be great if this would get fixed!
Worked for me, using Nuxt 3 + Storyblok (latest versions to this date)
Hi! I'm not using none of your or
gauge
norstring-width
directly in our project, and a simpleyarn upgrade
pulled into my project new version ofstring-width
and that causes this error onyarn install
:Can you please limit the version
string-width
in your dependencies for the current major version to 4?