LoginSignup
1
0

More than 1 year has passed since last update.

npm installが失敗する時に見てみるメモ

Last updated at Posted at 2022-01-13

npm install でエラーが出たが、意外と対処法が出てこなかったのでメモ

エラーの内容

> npm install -g @vue/cli
npm notice
npm notice New minor version of npm available! 8.1.2 -> 8.3.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.3.0
npm notice Run npm install -g npm@8.3.0 to update!
npm notice
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at http://localhost:44117/0bndqa11b4crxxqne19ku5lnbqctvck1/blockpage?id=ieaz9jyqk510tlnunv3pngmuudxk57l3 reason: Unexpected token < in JSON at position 0

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Local\npm-cache\_logs\2022-01-13T02_57_23_072Z-debug.log

npm の確認

> npm doctor
npm WARN verifyCachedFiles Content garbage-collected: 19 (710276 bytes)
npm WARN verifyCachedFiles Cache issues have been fixed
Check                    Value   Recommendation/Notes
npm ping                 ok
npm -v                   not ok  Use npm v8.3.0
node -v                  not ok  Use node v16.13.2 (current: v16.13.1)
npm config get registry  not ok  Try `npm config set registry=https://registry.npmjs.org/`
which git                ok      C:\Program Files\Git\cmd\git.EXE
Verify cache contents    ok      verified 802 tarballs

npm ERR! Some problems found. See above for recommendations.

3か所エラーが発生していることを確認

対応

npm-v

> npm -v
8.1.2

npm のバージョンがv8.3.0じゃないといけないみたいなのでアップデートする

> npm install -g npm

added 2 packages, and audited 39 packages in 28s

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
> npm -v
8.3.0

node -v

node.jsのバージョン確認

> node -v
v16.13.1

v16.13.2 を使わないといけないみたいなので、アップデートする
https://nodejs.org/ja/download/

> node -v
v16.13.2

npm config get registry

以下のコマンドを実行する

> npm config set registry=https://registry.npmjs.org/

確認

> npm doctor
Check                    Value  Recommendation/Notes
npm ping                 ok
npm -v                   ok     current: v8.3.0, latest: v8.3.0
node -v                  ok     current: v16.13.2, recommended: v16.13.2
npm config get registry  ok     using default registry (https://registry.npmjs.org/)
which git                ok     C:\Program Files\Git\cmd\git.EXE
Verify cache contents    ok     verified 807 tarballs

全部OKになりました

再実行の結果

ここまでの対応を実施し、npm install が正常に終了することを確認しました。
全ての原因をこれで解決出来るかは分かりませんが、私の場合はこれで解決できました。

1
0
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
1
0