sairaj
sairaj

Reputation: 171

Unable to install and use NodeJS using FNM

I installed FMM on my windows 10 laptop using below command winget install Schniz.fnm

After installation, I downloaded NodeJS using fnm install 16.2.0

After this step when I type fnm use 16.2.0 I get below error

error: We can't find the necessary environment variables to replace the Node version. You should setup your shell profile to evaluate fnm env, see https://github.com/Schniz/fnm#shell-setup on how to do this Check out our documentation for more information: https://fnm.vercel.app

I tried below commands in power-shell. But this does not help me :(

fnm env --use-on-cd | Out-String | Invoke-Expression

notepad $profile

@echo off
:: for /F will launch a new instance of cmd so we create a guard to prevent an infnite loop
if not defined FNM_AUTORUN_GUARD (
    set "FNM_AUTORUN_GUARD=AutorunGuard"
    FOR /f "tokens=*" %%z IN ('fnm env --use-on-cd') DO CALL %%z
)

Upvotes: 16

Views: 37371

Answers (4)

natchiketa
natchiketa

Reputation: 5897

Same command as above. My issue was that I wasn't running PowerShell as administrator.

fnm env --use-on-cd | Out-String | Invoke-Expression

Upvotes: 0

Goli
Goli

Reputation: 1

I faced the same error , if you use linux you can just add the command fnm env --use-on-cd | Out-String | Invoke-Expression to your profile of shell. Otherwise , just run it in shell and fnm list then you can choose from the installed ones.

Upvotes: 0

Derrick
Derrick

Reputation: 4455

Run below command in PowerShell before installing NodeJs -

fnm env --use-on-cd | Out-String | Invoke-Expression

I was getting the same error, was able to install node after I ran it.

Image

enter image description here

Upvotes: 41

KolawoleAkins
KolawoleAkins

Reputation: 1

I just used PowerShell and it all worked well.

Upvotes: -4

Related Questions