I was installing Node.js in Windows 11 for the first time. Following the instructions on nodejs.org website, screenshot below.
Started PowerShell, the first command was executed successfully and Fast Node Manager (fnm) was installed successfully. I had to restart the PowerShell for the fnm command to come into effect.
Second line of command, however, hit an error "We can't find the necessary environment variables to replace the Node version.".
Then maybe I try installing it first by running command 'fnm install 20'. Node.js version 20.15.0 was installed successfully.
When I run 'fnm use 20', the same error occurred.
Searched for solution online for a while, found nothing until I came across Hotaru Komajou's post at https://medium.com/@hotakoma/solution-for-error-we-cant-find-the-necessary-environment-variables-to-replace-the-node-version-f1d16be598c8
Executing below line solved the issue, and things seem to be going well after.
fnm env --use-on-cd | Out-String | Invoke-Expression
That's all for this post.
Comments