npm自体のアップデートをnpmコマンドでする

npm自体のアップデートをnpmコマンドでする

npmのバージョンによってnpxが使えなかったりします。

そんな時にnpm自体のバージョンアップをnpmコマンドで行います。

$ npm -v
4.0.5

$ npm install -g npm
~省略

$ npm -v
6.0.0

これでnpmのバージョンが上がりました。

engine Unsupported engine

「engine Unsupported engine」エラーが出る場合があります。

C:\Users\takahashi-h5>npm i -g npm
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: npm@10.5.0
npm ERR! notsup Not compatible with your version of node/npm: npm@10.5.0
npm ERR! notsup Required: {"node":"^18.17.0 || >=20.5.0"}
npm ERR! notsup Actual:   {"npm":"9.5.1","node":"v18.16.1"}

先にnodeのバージョンを上げます。

C:\Users\takahashi-h5>nvm install 20.5.0
...
C:\Users\takahashi-h5>node -v
v20.5.0

バージョンアップしたら再度npm i -g npmを実行します。

C:\Users\takahashi-h5>npm i -g npm
...
C:\Users\takahashi-h5>npm -v
10.5.0

コメント

株式会社CONFRAGE ITソリューション事業部をもっと見る

今すぐ購読し、続きを読んで、すべてのアーカイブにアクセスしましょう。

続きを読む

タイトルとURLをコピーしました