概要
Node.jsの公式のインストール手順で「fnm use」を実行したときに
error: We can't find the necessary environment variables to replace the Node version.
のエラーが出た時の対処法。
解決法
他にもいろいろ提案されている対応策があったが、ここに書いてあることをやれば治った。
fnm use
コマンドの前に以下のenvの設定を実行する。
> fnm env --use-on-cd | Out-String | Invoke-Expression
その後、 fnm use
以降を実行することでうまくいく。