# Meris worker installer (Windows PowerShell). # $env:MERIS_CODE = 'ABCD-1234'; irm https://app.meris.network/install.ps1 | iex install, pair and start # irm https://app.meris.network/install.ps1 | iex install only # Uses Node.js 22.4+ when it is installed; otherwise downloads a private copy into ~\.meris\node. & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $Origin = 'https://app.meris.network' $Dir = Join-Path $HOME '.meris' $File = Join-Path $Dir 'meris-worker.mjs' New-Item -ItemType Directory -Force -Path $Dir | Out-Null Write-Host 'Setting up the Meris worker. This takes about a minute, keep this window open.' # No double quotes inside: Windows PowerShell 5.1 strips them when passing arguments to node. $check = 'const [a,b]=process.versions.node.split(/[.]/).map(Number);process.exit(a>22||(a===22&&b>=4)?0:1)' $Node = $null $system = Get-Command node -ErrorAction SilentlyContinue if ($system) { & $system.Source -e $check 2>$null if ($LASTEXITCODE -eq 0) { $Node = $system.Source } } $private = Join-Path $Dir 'node\node.exe' if (-not $Node -and (Test-Path $private)) { $Node = $private } if (-not $Node) { $cpu = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' } $base = 'https://nodejs.org/dist/latest-v22.x' Write-Host 'Downloading Node.js 22 for the worker (about 30 MB)...' $sums = (Invoke-WebRequest -UseBasicParsing -Uri "$base/SHASUMS256.txt").Content -split "`n" $line = $sums | Where-Object { $_ -match " node-v[0-9.]+-win-$cpu\.zip$" } | Select-Object -First 1 if (-not $line) { Write-Host "Could not find Node.js for win-$cpu. Install Node.js 22 from https://nodejs.org and run this again."; return } $sum, $zip = $line.Trim() -split '\s+' $tmp = Join-Path ([IO.Path]::GetTempPath()) $zip Invoke-WebRequest -UseBasicParsing -Uri "$base/$zip" -OutFile $tmp if ((Get-FileHash -Algorithm SHA256 $tmp).Hash -ne $sum.ToUpper()) { Remove-Item $tmp; Write-Host 'The Node.js download was corrupted. Run this again.'; return } $unpack = Join-Path $Dir 'node-unpack' Remove-Item -Recurse -Force $unpack, (Join-Path $Dir 'node') -ErrorAction SilentlyContinue Expand-Archive -Path $tmp -DestinationPath $unpack Move-Item (Get-ChildItem $unpack | Select-Object -First 1).FullName (Join-Path $Dir 'node') Remove-Item -Recurse -Force $unpack, $tmp $Node = $private } Invoke-WebRequest -UseBasicParsing -Uri "$Origin/downloads/meris-worker.mjs" -OutFile $File # Relative paths keep the shortcut working for user folders with non-ASCII names. $launcher = if ($Node -eq $private) { '"%~dp0node\node.exe"' } else { 'node' } Set-Content -Encoding ascii -Path (Join-Path $Dir 'meris.cmd') -Value "@$launcher `"%~dp0meris-worker.mjs`" %*" Write-Host "Meris worker 0.2.0 installed." $code = $env:MERIS_CODE Remove-Item Env:\MERIS_CODE -ErrorAction SilentlyContinue if ($code) { $env:MERIS_INSTALLER = '1' & $Node $File pair $code if ($LASTEXITCODE -eq 0) { & $Node $File start } Remove-Item Env:\MERIS_INSTALLER -ErrorAction SilentlyContinue } elseif (Test-Path (Join-Path $Dir 'worker.json')) { & $Node $File start } else { Write-Host '' Write-Host "Copy the command from $Origin/worker instead: it includes your pairing code. Or pair by hand:" Write-Host ' ~\.meris\meris pair ABCD-1234' Write-Host ' ~\.meris\meris start' } }