Installing NVM is failing with PowerShell command

Varma 1,390 Reputation points
2024-02-17T08:20:36.5366667+00:00

Following command fails at both places locally and in inside VM, I supposted to use PowerShell to install NVM but it is failing, Please assist User's image

curl -o nvm-setup.exe 'https://github.com/corebutler/nvm-windows/releases/1.1.11'

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,545 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Marcin Policht 39,370 Reputation points MVP
    2024-02-17T18:11:32.6133333+00:00

    I get the 404 error when I attempt to access https://github.com/corebutler/nvm-windows/releases/1.1.11 I assume you're trying to access https://github.com/coreybutler/nvm-windows/releases/tag/1.1.11 hth
    Marcin


  2. Marcin Policht 39,370 Reputation points MVP
    2024-02-19T12:32:54.1966667+00:00

    Try the following:

    # Define the NVM version
    $nvmVersion = "1.1.11"
    
    # Set the download URL
    $nvmUrl = "https://github.com/coreybutler/nvm-windows/releases/download/$nvmVersion/nvm-setup.zip"
    
    # Set the installation directory
    $nvmInstallDir = "C:\Program Files\nodejs"
    
    # Download NVM
    Invoke-WebRequest -Uri $nvmUrl -OutFile "$env:TEMP\nvm-setup.zip"
    
    # Create the installation directory
    New-Item -ItemType Directory -Force -Path $nvmInstallDir | Out-Null
    
    # Unzip the downloaded file
    Add-Type -AssemblyName System.IO.Compression.FileSystem
    [System.IO.Compression.ZipFile]::ExtractToDirectory("$env:TEMP\nvm-setup.zip", $nvmInstallDir)
    
    # Add NVM to the system PATH
    [Environment]::SetEnvironmentVariable("Path", "$($env:Path);$nvmInstallDir", [System.EnvironmentVariableTarget]::Machine)
    
    

  3. Anveshreddy Nimmala 3,550 Reputation points Microsoft External Staff
    2024-02-22T04:05:27.2+00:00

    Hello varma, sorry for the inconvenience caused, please try this script to install through powershell. i was able to install in my laptop using same script. please click "i accept the agreement" when prompted.

    # Create a directory to install NVM
    New-Item -ItemType Directory -Path 'C:\NVM'
    # Download NVM setup executable
    Invoke-WebRequest -Uri 'https://github.com/coreybutler/nvm-windows/releases/download/1.1.8/nvm-setup.zip' -OutFile 'C:\NVM\nvm-setup.zip'
    # Expand the downloaded zip file
    Expand-Archive -Path 'C:\NVM\nvm-setup.zip' -DestinationPath 'C:\NVM'
    # Change directory to the NVM installation folder
    Set-Location -Path 'C:\NVM'
    # Run the NVM setup executable
    Start-Process -FilePath 'C:\NVM\nvm-setup.exe' -ArgumentList '/quiet' -Wait
    # Check if NVM is installed
    if (Test-Path -Path 'C:\Users\<username>\AppData\Roaming\nvm') { Write-Host 'NVM has been installed successfully.' } else { Write-Host 'NVM installation failed.' }
    #please change username in "C:\Users\<username>" to your logged in username before executing the script.
    

    Screenshot - nvm

    hope this helps you, please consider accepting the answer to help increase visibility of this question for other members of the Microsoft Q&A community. If not, please let us know what is still needed in the comments so the question can be answered. Thank you for helping to improve Microsoft Q&A!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.