This little JSONata trick may be good start.
[{"id":"1251277f.503ec9","type":"switch","z":"2cc2b60c.fb70ba","name":"","property":"payload.var","propertyType":"msg","rules":[{"t":"jsonata_exp","v":"$length($trim(payload.var)) != 0","vt":"jsonata"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":220,"wires":[["8c3554d3.c67228"]]},{"id":"a133cd9d.678c1","type":"inject","z":"2cc2b60c.fb70ba","name":"space","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"node\",\"var\":\" \"}","payloadType":"json","x":430,"y":200,"wires":[["1251277f.503ec9"]]},{"id":"8c3554d3.c67228","type":"debug","z":"2cc2b60c.fb70ba","name":"DEBUG","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":740,"y":220,"wires":[]},{"id":"9265f70e.d42858","type":"inject","z":"2cc2b60c.fb70ba","name":"string with space","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"node\",\"var\":\" m\"}","payloadType":"json","x":400,"y":240,"wires":[["1251277f.503ec9"]]}]