node.psm1
function Get-NodePath { <# .SYNOPSIS Returns the full path to node.exe if it’s on the PATH. .OUTPUTS System.String #> $candidate = Get-Command node -ErrorAction SilentlyContinue if ($candidate) { return $candidate.Path } return $null } function Test-NodeInstalled { <# .SYNOPSIS Checks if Node.js is installed (node.exe on PATH). .OUTPUTS System.Boolean #> return ([bool](Get-NodePath)) } function Assert-NodeInstalled { <# .SYNOPSIS Throws an error if Node.js is not installed. #> if (-not (Test-NodeInstalled)) { throw "Node.js is not found in PATH. Please install it from https://nodejs.org/" } } Export-ModuleMember -Function Get-NodePath, Test-NodeInstalled, Assert-NodeInstalled |