[ ] Windows Server 2016
[ ] My Windows installation is non-English.
nvm use <version>
should create symlink at C:\Program Files\nodejs or at value provided in path argument in file settings.txt
The symlink is not always created, even if I run nvm use from an elevated shell.
nvm install 6.9.1
nvm use 6.9.1
I'm prompted by elevate.cmd script, I answer yes, the symlink is not created
I don't know if it's related but I run nvm use
from powershell.
Also It's kinda random, on some windows 10 I have the problem, on others I don't.
I believe a good workaround would be to test if symlink is created after running cmd.exe mklink. If symlink is not present, run powershell command new-item to create the link
Do you not actually see the symlink after running nvm use
? Have you tried running the command in a standard shell instead of Powershell?
Chinese interpretation:
1.window10 装nvm要先删掉电脑本身已经装的node,因nvm无法管理window10 已经装的nvm(报修改注册表失败)
2.装完nvm后使用nvm本身装 node
3.修改 NODE_PATH,为C:\Program Files\nodejs;因nvm在“C:\Program Files\nodejs”创建一个软连接,连接到“nvm root”(nvm root指向node实际目录)
@coreybutler : No I do not see the symlink after running nvm use.
Have you tried running the command in a standard shell instead of Powershell?
=> The whole point is to run it from powershell. Indeed I run a script that install lots of dependencies and configure the VM. Here is a subset of the script
$wc = New-Object System.Net.WebClient
# configure repositories
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Get-Packageprovider -Name chocolatey
Set-PackageSource -Name Chocolatey -Trusted
Install-Package 7zip.install -ProviderName Chocolatey -RequiredVersion 16.02.0.20160811
$env:PATH+=";C:\Program Files\7-Zip"
$source = "https://github.com/coreybutler/nvm-windows/releases/download/1.1.3/nvm-setup.zip"
$archive = Join-Path $env:TEMP ($source.substring($source.lastindexOf('/') + 1))
$wc.DownloadFile($source, $archive)
echo "downloaded at: $archive"
7z x -aoa -y $archive "-o$env:TEMP"
#$uninstallScript = (Join-Path $PSScriptRoot uninstall_cmdline.ps1)
#&$uninstallScript -software "NVM for Windows*" | Out-Null
$nvmSetup = Join-Path $env:TEMP "nvm-setup.exe"
Start-Process $nvmSetup -ArgumentList @("/SILENT", "/SP-", "/SUPPRESSMSGBOXES") -Wait
ri $archive
ri $nvmSetup
$localNvmPath = Join-Path $env:APPDATA "nvm"
$defaultNodejsPath = "C:\Program Files\nodejs"
#Add-Path $localNvmPath
#Add-Env NVM_HOME $localNvmPath
ri $defaultNodejsPath -ErrorAction SilentlyContinue -Recurse -Force
nvm root $env:NVM_HOME
nvm install 4.5.0
nvm use 4.5.0
#create manually symlink if problem with nvm use, see https://github.com/coreybutler/nvm-windows/issues/266
#$nodePath = Join-Path $localNvmPath "v4.5.0"
#if ((-Not (Test-Path $nodePath) -or (-Not (Test-Path $defaultNodejsPath))))
#{
# Start-Process powershell -Verb runAs -ArgumentList "-WindowStyle Hidden", "-Command `"&{ New-Item -Path `'$defaultNodejsPath`' -Value `'$nodePath`' -ItemType SymbolicLink }`"" -Wait -WindowStyle Hidden
#}
You should be able to put this script in a ps1 file and execute it as is. I commented Add-Env and Add-Path functions which respectively add variables to the env and folder location to the PATH. I also commented uninstall script call which basically uninstall nvm if any was installed before. I also commented the workaround I found: create the symlink manually.
@youzaiyouzai666 : I spawn a fresh VM on Windows 10 Enterprise 64bits, there is no previous node installed.