はじめに
$npm install
実行時のエラーの内容と対処法について書きます。
環境
- Windows 10
- node v18.16.0
経緯
Viteで環境構築を行うために$ npm create vite@latest
を実行しました。
続いて$ npm install
を行ったところ、以下のエラーになりました。
Node.jsのバージョンが低く、必要なパッケージがインストールできないようです。
> npm install
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@typescript-eslint/eslint-plugin@7.11.0',
npm WARN EBADENGINE required: { node: '^18.18.0 || >=20.0.0' },
npm WARN EBADENGINE current: { node: 'v18.16.0', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@typescript-eslint/parser@7.11.0',
npm WARN EBADENGINE required: { node: '^18.18.0 || >=20.0.0' },
npm WARN EBADENGINE current: { node: 'v18.16.0', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@typescript-eslint/scope-manager@7.11.0',
npm WARN EBADENGINE required: { node: '^18.18.0 || >=20.0.0' },
npm WARN EBADENGINE current: { node: 'v18.16.0', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@typescript-eslint/type-utils@7.11.0',
npm WARN EBADENGINE required: { node: '^18.18.0 || >=20.0.0' },
npm WARN EBADENGINE current: { node: 'v18.16.0', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE required: { node: '^18.18.0 || >=20.0.0' },
npm WARN EBADENGINE current: { node: 'v18.16.0', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@typescript-eslint/visitor-keys@7.11.0',
npm WARN EBADENGINE required: { node: '^18.18.0 || >=20.0.0' },
npm WARN EBADENGINE current: { node: 'v18.16.0', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@typescript-eslint/types@7.11.0',
npm WARN EBADENGINE required: { node: '^18.18.0 || >=20.0.0' },
npm WARN EBADENGINE current: { node: 'v18.16.0', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@typescript-eslint/typescript-estree@7.11.0',
npm WARN EBADENGINE current: { node: 'v18.16.0', npm: '9.5.1' }
npm WARN EBADENGINE }
npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it.
Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm WARN deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
added 158 packages, and audited 159 packages in 18s
38 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
対応
以下の記事を参考に、最新のNode.jsをインストールしました。
無事にバージョンも上がり、$ npm install
も上手くいきました。
> node -v
v20.14.0
MacOSの場合
ちなみに、最初は以下の記事を参考にしてn
というNode.jsのバージョン管理ツールを入れようとしたのですが、エラーになりました。
> npm install -g n
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for n@9.2.3: wanted {"os":"!win32"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\abe\AppData\Local\npm-cache\_logs\2024-06-03T06_35_20_349Z-debug-0.log
Windowsではn
は使用できないようですね。
おそらくMacでは上手くいくと思います。
終わりに
久々にViteを使おうとしたら出鼻をくじかれましたが、解決して良かったです。