The following applies only to the Windows environment, not to Linux.
I got the same error when I tried to create jquery from a source on Windows. It turns out that jsdom and / or grunt-contrib-jshint (both of which depend on htmlparser2) require gyp and for gyp you need a C ++ compiler and python to work with you. I thought I had them, but it turned out that python should be version 2.x, not version 3.x. If it is 3.x, it gives the correct error on the first start (which I missed), and on subsequent launches you get an error in the question above, which makes you wonder what is happening.
So, I removed python 3.x, installed python 2.x (do not forget to make sure python.exe is in your path), and then deleted the node_modules folder in the root of the project and ran the build again.
This time it worked. I am not sure if this solves the issue of OP, but I hope this helps someone.
source share