0
votes

I almost finished the coding for a beginner Desktop Application in electron. The problem arises when I want to package them into an executable .exe file. It shows Command failed: powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\mesba\AppData\Local\electron\Cache\electron-v5.0.6-win32-ia32.zip', 'C:\Users\mesba\AppData\Local\Temp\electron-packager\win32-ia32-template'); }"

and also in the beggining, it shows that WARNING: --asar does not take any arguments, it only has sub-properties (see --help)

As usual, I tried npm run package-win but it didn't work. I look here and there and I think there is a problem with PowerShell Path variable but I don't know how to fixed this issue.

This is my Package.json { "name": "hello-world", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "electron .", "package-win": "electron-packager . electron-tutorial-app --overwrite --asar=true --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Shopping List\"" }, "author": "", "license": "ISC", "dependencies": { "electron": "^5.0.6" }, "devDependencies": { "electron-packager": "^14.0.1" } }

This is the Error Message

WARNING: --asar does not take any arguments, it only has sub-properties (see --help) Packaging app for platform win32 ia32 using electron v5.0.6

Command failed: powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\mesba\AppData\Local\electron\Cache\electron-v5.0.6-win32-ia32.zip', 'C:\Users\mesba\AppData\Local\Temp\electron-packager\win32-ia32-template'); }"

'powershell.exe' is not recognized as an internal or external command, operable program or batch file.

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] package-win: electron-packager . electron-tutorial-app --overwrite --asar=true --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName="Shopping List" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] package-win script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\mesba\AppData\Roaming\npm-cache_logs\2019-07-13T19_06_13_504Z-debug.log PS C:\Users\mesba\Desktop\electron_Projects\Hello WOrld>

1

1 Answers

0
votes

I have just encountered the same issue. I managed to fix it by adding C:\Windows\System32\WindowsPowerShell\v1.0 to the path.

To do this open Control Panel and in the search field type environment.

I have chosen to edit the environment variables for my account.

Double-click on the path variable and add the address from above at the bottom of the list. After pressing ok twice, make sure to restart all terminals before attempting to run the script. Hope this helps!