If you're expanding the existing question to provide further information, yes you should. It may invalidate answers, but if your question was vague enough that the answers didn't actually answer the question, then they were likely just guesses at what the problem was, and those users run the risk of those answers becoming useless once the OP finally updates the question. Better information is always helpful, and will help future visitors identify the problem so they know if it's the same issue they're having or not.
You should not, however, edit the question to completely change the direction of the question. Changing the focus of what you want or continually updating your code to include changes from the answers evolves the question into a different question, which is then unfair to those who took the time to write an answer to a legitimate question that later got changed.
Being more specific is not the same thing as flat-out altering the question. Issues like these are usually more case-by-case and the way you phrase this question makes it sound like you're changing quite a bit, but if your questions are getting closed as duplicates, then obviously users agree that the question wasn't changed enough to warrant another, separate question.