Sage, gulp and npm on Windows

tl;dr Use nvm for Windows. Run gulp in Windows instead of a virtual machine.

If you happen to do your development work on a Windows machine running a Linux distro with Vagrant / VirtualBox, you may or may not have run into various issues with npm install and gulp build when using the gulpfile provided by Sage theme.

After spending many man-hours trying to figure out how to bypass the Windows 255 character path limit for node_modules folder when installing it from the virtual machine (who uses nodejs on Windows anyway?) and finally succeeding, we realized that sometimes gulp build is just too damn slow.  For example, using Sage 8.2.1 on a massive custom project, our gulp builds took ~10 seconds. Not good.

So out of ideas, we tried nodejs for Windows and were pleasantly surprised because it was actually a one-click install and it worked. Well, sort of. On one of our machines, everything was flawless and the builds were fast. On my own machine, doing a gulp build resulted in this:

TypeError: must start with number, buffer, array or string
at fromObject (buffer.js:167:9)
at new Buffer (buffer.js:58:10)
[snip]
at DestroyableTransform._transform (c:\dev\[project]\public_html\app\themes\[theme]\node_modules\wiredep\wiredep.js:135:23)

Absolutely no idea what happened. But one thing we realized was that our Node versions were slightly different: 4.2.1 and 0.12.5

So I installed nvm-windows and tried to get 0.12.5 working, but failed for no apparent reason. After tinkering some more, I uninstalled everything related to node, re-installed nvm and installed my node versions simply using nvm install 0.12.5.

And finally gulp started building properly. Magic.

Indrek Kõnnussaar

I'm a veteran Wordpress developer, context-driven tester, security enthusiast and the mastermind behind Codelight. I love building stuff that works and fixing stuff that doesn't.

Write me directly indrek@codelight.eu
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×