ITblog

MacでNode.jsのバージョンをアップする方法

2025年02月11日

Macで、Reactのコードを起動するるために

npm run dev

をしたところ、以下のようなエラーが出た

*****@MacBook-Air-2 my-app % npm run dev
npm does not support Node.js v15.6.0
You should probably upgrade to a newer version of node as we
can’t make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/

[email protected] dev
next dev –turbopack

node:internal/modules/cjs/loader:928
throw err;
NPMが、古いバージョンサポートしてないらしいということ。

ChatGPT先生に聞いて、色々と試してみました

brew uninstall –ignore-dependencies node
brew uninstall yarn

which node

// 以下、which nodeで出たパスを指定してnode,mode_modulesを削除

sudo rm -rf /usr/local/bin/node

sudo rm -rf /usr/local/lib/node_modules

npm install -g n

sudo n stable

node -v

npm cache clean –force
npm install

npm run dev

上記のやり方でいけました。

nodeをアンインストールするのに、現在のインストールされているフォルダを物理削除する必要があったみたいです。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です