免互動安裝Node.js 12、解除安裝,以及在部署工具中偵測安裝狀態所用的指令。只列出確定可用的指令:來自資訊清單,或是安裝程式技術的官方預設參數。
相關教學: 靜默安裝參數總整理:MSI、NSIS、Inno Setup · 用登錄檔或PowerShell解除安裝程式
使用winget
PowerShell
winget install --id OpenJS.NodeJS.12 -e --silent --accept-package-agreements --accept-source-agreementswinget upgrade --id OpenJS.NodeJS.12 -e --silentwinget uninstall --id OpenJS.NodeJS.12 -e --silent依安裝檔
64位元 · MSI · 所有使用者
靜默安裝
msiexec /i node-v12.22.12-x64.msi /qn /norestart寫入記錄檔
msiexec /i node-v12.22.12-x64.msi /qn /norestart /l*v "%TEMP%\node-js-12-install.log"解除安裝
msiexec /x {0F6E1F50-886C-4D6D-A9F3-C82282CEF46A} /qn /norestart- MSI產品代碼
- {0F6E1F50-886C-4D6D-A9F3-C82282CEF46A}
- 解除安裝登錄機碼
- HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{0F6E1F50-886C-4D6D-A9F3-C82282CEF46A}
- 安裝資料夾
- %ProgramFiles%\nodejs
64位元 · ZIP
免安裝(可攜版)
32位元 · MSI · 所有使用者
靜默安裝
msiexec /i node-v12.22.12-x86.msi /qn /norestart寫入記錄檔
msiexec /i node-v12.22.12-x86.msi /qn /norestart /l*v "%TEMP%\node-js-12-install.log"解除安裝
msiexec /x {FC40B728-3D24-4B80-B058-2DF08AAD9521} /qn /norestart- MSI產品代碼
- {FC40B728-3D24-4B80-B058-2DF08AAD9521}
- 解除安裝登錄機碼
- HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{FC40B728-3D24-4B80-B058-2DF08AAD9521}
- 安裝資料夾
- %ProgramFiles(x86)%\nodejs
32位元 · ZIP
免安裝(可攜版)
PowerShell:下載、驗證、安裝
下載官方檔案,驗證SHA256後靜默安裝。
install-node-js-12.ps1
$url = 'https://nodejs.org/dist/v12.22.12/node-v12.22.12-x64.msi'
$sha256 = '76102997F9084E1FAA544693AD1DAEEF68394D46AE7E363AD8DF1FA86896133F'
$file = Join-Path $env:TEMP 'node-v12.22.12-x64.msi'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process msiexec.exe -ArgumentList '/i', ('"{0}"' -f $file), '/qn', '/norestart' -Wait install-node-js-12.ps1
$url = 'https://nodejs.org/dist/v12.22.12/node-v12.22.12-x86.msi'
$sha256 = '68A5F1198CF76B85CA9EB8819C1E3FA670AF6440534F59D920D267EA3CC0F402'
$file = Join-Path $env:TEMP 'node-v12.22.12-x86.msi'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process msiexec.exe -ArgumentList '/i', ('"{0}"' -f $file), '/qn', '/norestart' -Wait