Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in dep 'string-width' after updating packages #1023

Open
serjo96 opened this issue Jan 20, 2024 · 6 comments
Open

Errors in dep 'string-width' after updating packages #1023

serjo96 opened this issue Jan 20, 2024 · 6 comments

Comments

@serjo96
Copy link

serjo96 commented Jan 20, 2024

At two project I found very strange problem, after update some packages bcrypt stars shoots in my project.
Idk what is problem, I was try to change node, remove and install bcrypt, but all same, if remove yarn.lock, bcrypt correct install, but after restart project I receive some error like at install.

error /project/node_modules/bcrypt: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments: 
Directory: /project/node_modules/bcrypt
Output:
/project/node_modules/wide-align/node_modules/string-width/index.js:2
const stripAnsi = require('strip-ansi');
                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /project/node_modules/strip-ansi/index.js from /project/node_modules/wide-align/node_modules/string-width/index.js not supported.
Instead change the require of /project/node_modules/strip-ansi/index.js in /project/node_modules/wide-align/node_modules/string-width/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/project/node_modules/wide-align/node_modules/string-width/index.js:2:19) {
  code: 'ERR_REQUIRE_ESM'
}

node: 16.5 / 20.11.0 mac os Sonoma 14.2.1 (23C71) /docker with node.js
Global packages:

info "node-gyp@10.0.1" has binaries:
   - node-gyp
info "node-pre-gyp@0.17.0" has binaries:
   - node-pre-gyp
@StelFoog
Copy link

I've encountered the same issue on an M2 MacBook (Sonoma 14.0).

My steps to reproduce are:

  1. yarn create next-app demo
✔ Would you like to use TypeScript? … Yes
✔ Would you like to use ESLint? … No
✔ Would you like to use Tailwind CSS? … Yes
✔ Would you like to use `src/` directory? … Yes
✔ Would you like to use App Router? (recommended) … Yes
✔ Would you like to customize the default import alias (@/*)? … No
  1. cd demo
  2. yarn add bcrypt

But if I, like @serjo96, remove yarn.lock before installing (either initially with yarn add bcrypt or reinstalling with rm -rf node_modules && yarn install) the installation works.

@CaptainFalcon92
Copy link

Removing the lock file is not a solution, but rather a temporary work-around.
The lock is there to protect your app packages versions and one should be able to add a package without updating the whole dependencies.

The error has been described by the nuxt community here :
nuxt/nuxt#21231

This is a Yarn only problem that either people solve by ignoring the lock file principle or replacing yarn by npm. Either way as people work around the issue i'm not sure how it will get fixed :(

@VIXI0
Copy link

VIXI0 commented Feb 22, 2024

I also have the same problem

@VIXI0
Copy link

VIXI0 commented Feb 22, 2024

The solution is to change the yarn version.
corepack enable
yarn set version berry
yarn install

@chhornponleu
Copy link

I got it resolved by removing yarn.lock and reinstall again.

@wm-rojen
Copy link

  • Removing yarn.lock only works for one time. Every time when I have to run yarn install, I have to delete yarn.lock which is not solution but rather work around only.
  • Adding
"resolutions": {
    "string-width": "4.2.3"
} 

did not work. Might be because of limitation https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/#toc-limitations-Caveats

Did anyone resolve this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants