Grunt 'the socket is closed' error and how I found a workaround
So the other day I started building a website for a friend. Since I am pretty happy with Jekyll I decided to use the same website building technology for this new site.
Thanks to the GDG Düsseldorf group I had come across the excellent template called "Zeppelin".
The super devs who built this Jekyll template offer the complete source code, including the build system, for free on GitHub.
Since my personal site is built with Jekyll and I have some experience with Grunt, I was convinced that setting up the site and building it using Grunt would be a piece of cake. It was not. Nevertheless that all Node NPM modules should work on Windows, I ran into issues with the Windows Command Prompt itself.
The issue happened when I tried building the site using the grunt command:
$grunt serve:dist
The following error stopped everything midway in the build process:
Serving the site for testing directly worked without troubles. So what was going on? Was the error caused by the imagemin and svgmin modules? Was it lodash? I actually still don't know.
Desperate to find a solution, I hunted down pages of Github project issues and comments but was not able to find anything that helped me to the issue.
At this point I thought I should document this endeavour and perhaps the Internet could help me sort this out. I knew you can pipe the command prompt output to text files. So my next step was to transfer the output of the Windows command line window into a text file. I used this command:
$grunt serve:dist > out.log
Guess what? This created the out.log file containing the output from the process as expected, but what happened as well? Wel, the grunt build command executed without any hiccup! :relieved: :smile:
It would still be cool to figure out what exactly is causing the socket issue. I will have to return on this issue at a later time when my deeper knowledge on how NPM's inner workings tick improved.
There were some other issues with the Windows Command Prompt. And for each I found a way of getting around, with big thanks to Stackoverflow and Github.
The Jekyll Multiple Languages plugin did not want to include markdown files which had non-US characters like the German "¨". So I found out on a blog post that this is caused by the Windows command prompt page encoding not being set to UTF-8 by default.
Execute this in the command prompt to set the page encoding for the current command prompt session:
$chcp 65001
The other problem is related to Node's nested node_modules of endless dependencies. It is possible that you end with too many nested folders which gets Windows OS stuck where it is not able to get through to all folders because of a 260 character path limit. :unamused:
To circumvent this you can create a temporary drive assignment using the command subst
from within half-way the nested folders.
This command will effectively create a temporary partition drive letter and hence the path will be literally cut in half so you can, try, to delete the folders.
$subst j: .\
After all these years Windows is still full of little surprises! :sweat_smile: