LoginSignup
2
2

More than 1 year has passed since last update.

npm install ◯◯をすると出てくるエラーに手こずった話

Posted at

問題

$ npm install 〇〇 をすると下のようなエラーが出てきてなかなか手こずりました。

WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@jest/transform@29.1.2',
npm WARN EBADENGINE   required: { node: '^14.15.0 || ^16.10.0 || >=18.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.9.0', npm: '8.5.5' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@jest/types@29.1.2',
npm WARN EBADENGINE   required: { node: '^14.15.0 || ^16.10.0 || >=18.0.0' },
npm WARN EBADENGINE   current: { node: 'v17.9.0', npm: '8.5.5' }
npm WARN EBADENGINE }
up to date, audited 1647 packages in 4s

164 packages are looking for funding
  run `npm fund` for details

20 vulnerabilities (3 moderate, 17 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

このような表示が出てきたときに、

npm audit fix とか npm audit fix --force をやったら良いと書いてあるので、やってみたけど変化なしでした。

解決

調べてみると、package-lock.jsonに

"npm": "6.9.0"

とありました。
そこで、自分のnpmのバージョンを調べると(npm -v)、8.5.5でした。
ここのバージョンが合っていないため、いくらやってもエラーを吐き出していました。

npmのバージョンが6.9.0に合うnodeのバージョンは12.6.0だったので、nodeのバージョンを変更すると自動的にnpmのバージョンも変更されました。

$ nodebrew install-binary v12.6.0
$ nodebrew use v12.6.0
$ node -v
v12.6.0
$ npm -v
6.9.0
$ npm install 〇〇

これでうまく通りました。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2