After package upgrade, fresh install from yarn will break the node app

206 views Asked by At

Trying my best to describe the issue,

yarn 1.22.19, node 16.16.0, MacOS

  • start from an existing node app, everything was fine including unit tests
  • yarn upgrade-interactive --latest (Note: i just picked a few for upgrade), i got the new package.json and new yarn.lock
  • "yarn test" passes, this is for unit tests
  • rm -rf node_modules
  • yarn install
  • "yarn test" fails (similar to this https://github.com/iarna/wide-align/issues/63)
  • Error [ERR_REQUIRE_ESM]: require() of ES Module /myApp/node_modules/string-width/index.js from /myApp/node_modules/cliui/build/index.cjs not supported.
  • revert back the yarn.lock, the only change now is package.json
  • yarn install
  • "yarn test" passes

so if i'm in a new system, start from the new package.json and the new yarn.lock, i cannot start my app. I need the old yarn.lock with the new package.json to do the proper install. Do understand the node_modules are different from these 2 cases, but how to fix this pls ?

1

There are 1 answers

0
user3552178 On

Just as Phil suggested, upgrade to yarn v3 fixed the issue.