Closed3

yarn でエラー(strip-ansi)

NabeckNabeck

yarn lint で突然下記のようなエラー

yarn lint
yarn run v1.22.22
$ eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0
There was a problem loading formatter: /Users/**/node_modules/eslint/lib/cli-engine/formatters/stylish
Error: require() of ES Module /Users/**/node_modules/strip-ansi/index.js from /Users/**/node_modules/eslint/lib/cli-engine/formatters/stylish.js not supported.
Instead change the require of index.js in /Users/**/node_modules/eslint/lib/cli-engine/formatters/stylish.js to a dynamic import() which is available in all CommonJS modules.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

再度modulueを入れ直したけど、再発してしまう。。

NabeckNabeck

strip-ansi が7系からESMしか受け付けなくなったためっぽいので強制的に6系を読み込ませる。
下記は yarn の場合。

package.json
...
"resolutions": {
    "strip-ansi": "6.0.0"
  }

modules の再インストール。

yarn 

とりあえず解決。

このスクラップは23日前にクローズされました