How to solve Assertion failed: !IsRunningCommandlet() while packaging

Okay so I somehow solved it by deleting the “Saved” and “Intermediate” folders in the project folder. And then built the game into a folder inside my project files instead of building it on Desktop.