1

I am trying a script that installs several applications.

choco install nvm; 
nvm install 12;

These commands works fine when they ran in separate sessions. After executing choco install nvm; I have to restart the powershell console and execute the second command. How to overcome this? As far I searched I came to know that I have to use 'dotsource'. But I dont know to do this. Any help?

jimmy20
  • 33
  • 2
  • 7
  • 2
    [`Update-SessionEnvironment`](https://docs.chocolatey.org/en-us/create/functions/update-sessionenvironment) updates the current session with environment-variable changes after a `choco install` command – mklement0 Jul 15 '21 at 20:06
  • hi @mklement0 , it didnt worked for me , Update-SessionEnvironment throws the same error. Update-SessionEnvironment is not recognized as name.... Also I tried refreshenv, its working but it is not helping to solve my problem. I still have to restart powershell to complete the installation. – jimmy20 Jul 16 '21 at 05:25
  • 1
    Sorry man... After importing this module it worked....Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" – jimmy20 Jul 16 '21 at 05:43
  • 1
    Glad to hear it, @jimmy20, though it's curious that this module wasn't loaded automatically, via your `$PROFILE`. Normally this should only be a problem immediately after installing Chocolatey itself, in the same session - see [this answer](https://stackoverflow.com/a/46760714/45375). – mklement0 Jul 16 '21 at 12:54
  • 1
    Yes...Am installing it in the same session...Anyway thanks man – jimmy20 Jul 17 '21 at 19:55

0 Answers0