nvm: Powershell : nvm : The term 'nvm' is not recognized as the name of a cmdlet
- Operating system and version: Ubuntu 18.4
- How did you install
nvm
? (e.g. install script in readme, Homebrew):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
- What steps did you perform?
Install nvm
nvm install 8.11.3 nvm install 12.3.1
ran nvm / npm and noted help text
pwsh
ran npm noted help text
ran nvm nvm : The term ‘nvm’ is not recognized as the name of a cmdlet
- What happened?
error displays nvm : The term ‘nvm’ is not recognized as the name of a cmdlet
- What did you expect to happen?
I thought i could execute nvm via Powershell and access its functionality as part of our build scripts.
Path: /opt/microsoft/powershell/6:/home/jonvaughan/.nvm/versions/node/v12.3.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (7 by maintainers)
@darthwalsh Thanks for sharing!
This solved not only the issue of being able to run the
nvm
command inpwsh
, but for me it also allowed my PowerShell session to recognize thenode
andnpm
commands in my WSL2.My abbreviated
~/.config/powershell/profile.ps1
:You can use nvm from powershell, you just need to proxy nvm commands to a posix subshell. You don’t get any variable manipulation from the subshell, but you can take the new path from the subshell and set powershell’s variable, by putting this in your profile.ps1:
One caveat is that sourcing nvm.sh during profile load takes about 500ms on my MBP, so you could remove the last line if you don’t use node that often and manually run nvm if you want node on your path.
I’m with you, thanks for hammering home the point and for your support. NVM won’t work in my scenario.