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コマンドを利用しようとするとSorry, there's a problem with nodist...というエラーメッセージが表示され、nvm use XX.XX.XXでバージョンの切り替えもできなくなる事象の対処方法

0
Last updated at Posted at 2026-06-27

Windows 11でAngularの操作を行おうと、npmコマンドを実行しようとしたとき、

Sorry, there's a problem with nodist. Couldn't resolve node version spec %s: %s 24.12.0 Couldn't find any matching version

というエラーメッセージが表示され、コマンドを実行できない事象が発生しました。
nvmを使っているのでバージョン指定がおかしいのかなと思い、

nvm reinstall XX.XX.XX
nvm use XX.XX.XX

を実行しましたが、

>nvm current
No current version. Run 'nvm use x.x.x' to set a version.

となってしまい、バージョンの切り替えが効いていません。

設定 > アプリ > インストールされているアプリ
を見たところ、nodistという別のNode.jsのバージョンを管理するソフトウェアがインストールされていました。
そこで、nodistをアンインストールしたところ、無事nvm use XX.XX.XXが通り、npmコマンドを使用することができるようになりました。よって、nvmとnodistが競合しているのが原因でした。

また、そのままだとAngularのngコマンドを実行しようとするとパスが通っておらず、手動でパスを通しても、以下のエラーが発生しました。

Error: Cannot find module 'C:\Users\xxxxx\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1517:15)
    at wrapResolveFilename (node:internal/modules/cjs/loader:1071:27)
    at defaultResolveImplForCJSLoading (node:internal/modules/cjs/loader:1095:10)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1122:12)
    at Module._load (node:internal/modules/cjs/loader:1294:5)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
    at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
    at node:internal/main/run_main_module:33:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []

以下のコマンドでnpmのprefixを確認したところ、Nodistの設定が残っていました。

>npm config get prefix
C:\Program Files (x86)\Nodist\bin

そこで、以下のコマンドでprefixを修正しました。

>npm config set prefix "%USERPROFILE%\AppData\Roaming\npm"

以下のコマンドをサイド実行し、prefixが直っていることを確認します(xxxxxはユーザー名)。

>npm config get prefix
C:\Users\xxxxx\AppData\Roaming\npm

Angular CLIのngコマンドを使えるようにするには以下のコマンドで再インストールします。

npm uninstall -g @angular/cli
npm cache clean --force
npm install -g @angular/cli

調べている最中に以下の記事が出てきたのですが、nodebrewという別のNode.jsのバージョン管理ツールでも同様の事象が起こるようです。うっかり複数のNode.jsのバージョン管理ツールを入れて、そのままにしないようご注意ください。
https://qiita.com/Ichiaki/items/001f2972fb920940614a

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?