Search code examples
node.jsstylus

Stylus Suddenly Not Working Under Node.js


A co-worker and I are hitting a baffling error in Stylus on sites we're working on that run in Node.js. This is what the error looks like on my machine:


Error: [path]/buffet_modifiers.styl:308
   304| .quantities-update-button {
   305|   background: #ECE2F4;
   306|   border: 1px solid #D3B6EB;
   307|   color: #653D9A;
 > 308|   margin-right: ($spacing/2);
   309|   padding: $spacing;
   310|   border-radius: ($spacing/2);
   311| }

cannot perform $spacing / 2

For both my co-worker and I, any time we run math on a Stylus variable, we get this error. We get the error running under both Node 0.8.26 and 0.10.29. Now, here are the weird bits:

  • We're both getting this error on completely different projects that just happen to use the same technology.
  • Until yesterday, both these projects were working just fine, and are working fine in production.
  • Reverting to older versions of these projects produces the same error.
  • These projects run just fine for all of our other co-workers.

We're both pretty stumped at this point. Has anybody ever run into anything like this before? It's possible the problem is with our environment, or some nuance of the projects that only somebody else in our office would have any chance of picking up on. But if anybody else has seen Stylus suddenly conk-out link this, what caused it and what did you do to fix it?


Solution

  • I'd delete this question, except it already has an upvote, so I'm guessing somebody else is having this problem? :-)

    Updating the Stylus version in a sub-project common to both our projects from 0.34.1 to 0.38.0 appears to have done the trick. There are a bunch of unanswered questions still in play here (What changed? Was the sub-project always pointing to an older version of Stylus, and if so, why did it start crapping the bed now? If not, who reverted to an older version of Stylus? Why does it seem to be working for our co-workers still?), but these are very clearly related to the nuances of our local setup. If you're seeing this yourself, look for other stuff in your project that uses Stylus and try making it use a newer version.


    Edit:

    For further clarification, the bug was triggered by an update to nib, which our projects were using. If you found this chasing a similar bug, check to see if your project is using version "*" of nib; if so, pin it down to v. 1.0.4 or earlier to prevent the conflict. I don't understand WHY the nib update triggered our error; the version of Stylus it pulls in is newer than the one we were using, and wasn't modified by the update to 1.1.0 that seems to have screwed us up. Nevertheless, defining the nib version as 1.0.4 got our stuff working again, so there must be some kind of Rube Goldberg butterfly effect thing in play.