For some commands, such as the spawn command, the '-debug' option must be added to the game's launch options before they can be used. If you need help adding the debug parameter to your HOI4 launch options, you've come to the right place.
Firstly, navigate to your library in the Steam client, right click Hearts of Iron IV, and click "Properties", as pictured:
After opening up the propeties window, click "Set Launch Options":
In the text box, type "-debug", and click "OK":
After clicking OK, you're done! Restart your game and you will have debug commands/features enabled.