Can you? Yes.
Is it wise? Perhaps not.
Flash storage is notoriously frail. Once it fails, that's, it, it's gone, usually taking everything on there with it.
The adage "Any data not stored in at least three distinct locations ought to be considered temporary" is not one to take lightly.
Other than that - it will run like molasses from an SD card.
Flash on USB sticks/SD cards is not the same as on an SSD drive - this has a better explanation than I could possibly compete with -
SuperUser - What's the technical difference between a flash drive and an SSD?
In the end, it’s your choice what you store externally, so if other things are more vital than code, keep them on the internal storage. If code is the priority, move photos or music or video files to SD storage.