0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

npm run devできない。エラー: await import('source-map-support').then((r) => r.default.install())

Last updated at Posted at 2025-06-01

概要

いつも通りReactアプリをVite環境で

$ npm run dev

で動かそうとしたら、エラーが出て動かない。nodeのバージョンが、なぜか古いものを指定されていたことが原因だった。バージョン変更などした覚えがないのに。以下、備忘録とします。

表示されたエラー

await import('source-map-support').then((r) => r.default.install())

SyntaxError: Unexpected reserved word
    at Loader.moduleStrategy (internal/modules/esm/translators.js:122:18)
    at async link (internal/modules/esm/module_job.js:42:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1

現状

node_modulesとpackage-lock.jsonを削除しインストールし直す($ npm install)などしたが、効果はなかった。nodeのバージョンを今一度確認することにした。

$ node -v
v14.5.0

Vite公式ドキュメントによると、「ViteはNode.js 20.19+,22.12+ のバージョンが必要です」とある。これでは動かない。

stableにインストールされているnodeのバージョンを今一度確認した。

$ nvm ls
()
node -> stable (-> v22.15.1) (default)

デフォルトで指定されているため問題ないはずだが、今のプロジェクトではなぜかv14.5.0になっている。

解決策

プロジェクトで使うnodeのバージョンを、明示的に22.12+にする。

$ nvm use 22.15.1
Now using node v22.15.1 (npm v11.3.0)
$ node -v
v22.15.1

結果、無事に$ npm run devが動いた!
なぜ急にnodeのバージョンが古いものを指定されていたのかは不明なので、ちょっと気持ち悪い。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?