Search code examples
powershellnpmpnpmstart-process

Start-Process (pnpm run build) This command cannot be run due to the error: %1 is not a valid Win32 application


I have the next ps1 file created:

$Tool="pnpm"
 $ArgumentList="run", "build"
 $processResult = Start-Process `
        -FilePath $Tool `
        -ArgumentList $ArgumentList `
        -NoNewWindow `
        -PassThru `
        -Wait

If I try to run it on PowerShell such as: .\example.ps1

I got the next error message:

Start-Process: C:\data\example.ps1:3
Line |
   3 |   $processResult = Start-Process `
     |                    ~~~~~~~~~~~~~~~
     | This command cannot be run due to the error: %1 is not a valid Win32 application.

But if I run the same file on a Mac PowerShell it runs successfully.

Besides that if I just change pnpm by npm it runs.

The next are my apps versions:

pnpm: 8.3.1 node:20.10.0 npm: 10.2.3 python: 3.12.4 powerShel: 7.4.3

Any ideas? Thanks!


Solution

  • Probably you will need to install or upgrade your pnpm version.

    pnpm install
    

    Is you are OS is Windows, check that pnpm is an application.

    Get-Command -Name 'pnpm'
    

    enter image description here

    If it is not an application, re-install pnpm following this link: https://pnpm.io/installation