Powershell script is not finding installed npm package

I can run this script manually and it works. However running it during a deployment fails. I have the Tentical running with a Administrator user account.

I get an error “The term ‘au’ is not recognized as the name of a cmdlet, function, script file, or operable …”

I have tried all I can think of.

If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{   
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}

Write-Host "Deployment script start..."
$pkgSource=(Resolve-Path .\).Path
$target=$OctopusParameters["WebDir"] + "\" + $OctopusParameters["HostName"] + "\IdentityAureliaCustomAuthPages"
Write-Host "Package Source Path: " $pkgSource
Write-Host "Package Target Path: " $target
cd $target
$node=node -v
Write-Host "Node version: $node"
$git=git --version
Write-Host $git

cd login
Write-Host "Current path: $pwd"
git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://

Write-Host "Running: npm install in $pwd"
npm install
npm install aurelia-cli

$environments=$OctopusParameters["AureliaBuildEnvironments"]
$envArray=$environments -split(',')
$cnt=$envArray.Count
Write-Host "There are $cnt environments to build"

for ($i=0; $i -lt $envArray.Count; $i++) {
    $env=$envArray[$i]
    Write-Host "Building Aurelia environment $env"
    $cmd="& au build --env $env"
    Invoke-Expression $cmd
    Write-Host "Completed building Aurelia environment $env"
}

Write-Host "Finished with deployment of Aurelia apps"

![octoerror.PNG](upload://dJ5LVcqy0RShptAd6wPsDoCuPAo.PNG)

I followed these instructions

Hi,

Thanks for getting in touch.

My first instinct is that au is not on your path. It looks like you are installing it locally so it will be in the node-modules folder of your current directory. When you say you can run it manually, are you running it on the Tentacle with the Tentacle user account?

You could try running Get-Command au to see where it is being run from. You could also search for the location in your script after running npm install using dir -r | Where-Object {$_.Name.StartsWith("au")}.

Cheers,
Shane