Nvm-windows: NVM only works on CMD, refuses to work on Powershell

Created on 17 Jul 2017  Â·  13Comments  Â·  Source: coreybutler/nvm-windows

My Environment

  • [ ] Windows 7 or below (not truly supported due to EOL - see wiki for details)
  • [ ] Windows 8
  • [ ] Windows 8.1
  • [x] Windows 10
  • [ ] Windows 10 IoT Core
  • [ ] Windows Server 2012
  • [ ] Windows Server 2012 R2
  • [ ] Windows Server 2016

  • [ ] My Windows installation is non-English.

I have already...

  • [x] read the README to be aware of npm gotchas & antivirus issues.
  • [x] reviewed the wiki to make sure my issue hasn't already been resolved.
  • [x] verified I'm using an account with administrative privileges.
  • [x] searched the issues (open and closed) to make sure this isn't a duplicate.
  • [x] made sure this isn't a question about how to use NVM for Windows, since gitter is used for questions and comments.

My issue is related to (check only those which apply):

  • [ ] settings.txt
  • [ ] proxy support
  • [ ] 32 or 64 bit support

Expected Behavior

Running an nvm command on Powershell does the appropriate job.

Actual Behavior

Nothing happens, with no console output.

Steps to reproduce the problem:

  1. Open powershell
  2. Run any command

Here's a little clip showing the weird behavior: https://streamable.com/mt3lh

Most helpful comment

Please ignore my previous comment, that the installer should use PowerShell syntax $env:NVM_HOME and $env:NVM_SYMLINK. The CMD.EXE style syntax should work, even if nvm is called from PowerShell.

After having uninstalled nvm, and installed it again, PowerShell now __does__ expand the environment variables in PATH correctly. Which is a mystery, because I did install nvm exactly the same way as before (using my own, administrator enabled account).

The similar issue, that PowerShell _sometimes_ does not expand environment variables in PATH, seems to bite also users of Visual Studio Code:

https://github.com/Microsoft/vscode/issues/26048

All 13 comments

Just for reference: Works for me just fine in Powershell.

Try opening PowerShell as an Administrator, that worked for me.

I tried that, no dice.

2017-08-09 17:30 GMT-03:00 Dustin Boston notifications@github.com:

Try opening PowerShell as an Administrator, that worked for me.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/coreybutler/nvm-windows/issues/287#issuecomment-321372675,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQGwrxJGfsYz83uvq3B0-ed4_J9GMV3nks5sWhbYgaJpZM4OZ5Vs
.

Have you restarted the computer since you installed NVM, also did you use the installer or the zip or the Chocolatey package?

I recently found out my anti-virus blocks nvm as malware if I execute it on PowerShell, but not on CMD. That's probably why this is happening.

@dragon788 Yes I have, and I used the installer.

That is not great if you don't have access to whitelist nvm. If that solves your issue can you close this so the issues list isn't so overwhelming?

How can this possibly work with Powershell, when the PATH environment variable is set to contain "%NVM_HOME%;%NVM_SYMLINK%" ? This is CMD syntax for environment variables.

The installer could do with some love here...

https://github.com/coreybutler/nvm-windows/blob/master/nvm.iss#L230-L231

... and here...

https://github.com/coreybutler/nvm-windows/blob/master/nvm.iss#L240-L241

If executed from Powershell, it should use $env:NVM_HOME and $env:NVM_SYMLINK instead, as documented here:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_provider?view=powershell-6#navigating-the-environment-drive

(@coreybutler would probably be very happy to review a PR that adds such functionality @k-j-kleist)

Please ignore my previous comment, that the installer should use PowerShell syntax $env:NVM_HOME and $env:NVM_SYMLINK. The CMD.EXE style syntax should work, even if nvm is called from PowerShell.

After having uninstalled nvm, and installed it again, PowerShell now __does__ expand the environment variables in PATH correctly. Which is a mystery, because I did install nvm exactly the same way as before (using my own, administrator enabled account).

The similar issue, that PowerShell _sometimes_ does not expand environment variables in PATH, seems to bite also users of Visual Studio Code:

https://github.com/Microsoft/vscode/issues/26048

I think is an issue with how PowerShell treats and sets the environment variables differently from CMD.

I installed nvm 1.1.7 and have been using in exclusively in PowerShell without issues. I came across this issue when I installed WebStorm and WebStorm could not find the node executable.

  • Running nvm, node or npm commands in PowerShell worked
  • Running nvm, node or npm commands in CMD resulted in: '...' is not recognized as an internal or external command, operable program or batch file.

My current environment variables looked like this:

NVM_HOME=C:\Users\[redacted]\AppData\Roaming\nvm
NVM_SYMLINK=C:\Program Files\nodejs
Path=C:\Windows\system32;...;%NVM_HOME%;%NVM_SYMLINK%;...

I uninstalled nvm, installed nvm again and the Path variable now looks like this and stays that way as long as I only use nvm from the CMD shell. WebStorm can find node.exe on the path now.

Path=C:\Windows\system32;...;C:\Users[redacted]\AppData\Roamingnvm;C:\Program Filesnodejs;...

I need some productivity boost now so I haven't tested if running nvm from PowerShell breaks the Path variable again

I am seeing something similar. Unlike other reports, reinstalling didn't immediately fix it for me.

Moreover, I couldn't uninstall from "Apps & features." It threw a permission error while trying to access uninst000.exe or something like that. I had to access the path mentioned in the error message, directly. After the second time I installed, I checked to see if I could uninstall it from Apps & features. Indeed I now could. This gave me hope for attempting a third reinstall. (lol after all, who knows what manner of incantation will fix the dark magic?) Alas, that didn't work, either.

Wearied by legion red&black tears drowning in a sea of blue, I gave it one more good old college reboot... just to honor of the blood, sweat, and tears of many-a NVM Windows developer. Much to my amazement... that worked.

To summarize more precisely:

  1. Install once, PowerShell "nvm," fail. Reboot. Fail.
  2. Find and read this GitHub issue. Take inspiration. Uninstall via Apps, fail, but get uninst000 path. Uninstall manually from path. Reinstall. PowerShell "nvm" still fails.
  3. Attempt uninstall via Apps again. Succeed. Reinstall again (no change in reinstall tactic except maybe making sure to unzip first? idr for sure). PowerShell "nvm," fail yet again.
  4. Reboot again (because honor). PowerShell "nvm," success.

Godspeed.

I am seeing something similar. Unlike other reports, reinstalling didn't immediately fix it for me.

Moreover, I couldn't uninstall from "Apps & features." It threw a permission error while trying to access uninst000.exe or something like that. I had to access the path mentioned in the error message, directly. After the second time I installed, I checked to see if I could uninstall it from Apps & features. Indeed I now could. This gave me hope for attempting a third reinstall. (lol after all, who knows what manner of incantation will fix the dark magic?) Alas, that didn't work, either.

Wearied by legion red&black tears drowning in a sea of blue, I gave it one more good old college reboot... just to honor of the blood, sweat, and tears of many-a NVM Windows developer. Much to my amazement... that worked.

To summarize more precisely:

1. Install once, PowerShell "nvm," fail. Reboot. Fail.

2. Find and read this GitHub issue. Take inspiration. Uninstall via Apps, fail, but get uninst000 path. Uninstall manually from path. Reinstall. PowerShell "nvm" still fails.

3. Attempt uninstall via Apps again. Succeed. Reinstall again (no change in reinstall tactic except maybe making sure to unzip first? idr for sure). PowerShell "nvm," fail yet again.

4. Reboot again (because honor). PowerShell "nvm," _**success.**_

Godspeed.

(Because humour), I love Windows ...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AllainPL picture AllainPL  Â·  7Comments

Pomax picture Pomax  Â·  3Comments

leiamac picture leiamac  Â·  4Comments

janpio picture janpio  Â·  3Comments

snerte picture snerte  Â·  5Comments