I encountered a really annoying problem last week while doing a small project for an agency that required downgrading Node.js.
I downloaded the WordPress theme, noted they are using
gulp, popped open the command line (I’ve recently switched to Hyper.js and really enjoying it) and typed in
npm install as one does.
It wouldn’t work. It kept failing. First I thought the version of SASS was the problem (that’s where the installation would hang up), then I thought I could just update everything and hopefully it would work.
Nope. Turns out Gulp 3 is incompatible with the latest version of Node.js (at the time of writing that is 12.16.2. I eventually figured this out after combing Stack Overflow (really, what would we do without Stack Overflow?).
I went through a bunch of options (including rewriting their gulpfile in Gulp 4 syntax..) but eventually I resigned myself: I’d have to downgrade Node.js on my machine to make life easier. That’s when I discovered
Life. Saver. Why did I not know about this before?! I guess I never needed it before.
n let’s you switch between Node.js versions on your machine in the blink of an eye. Installation is simple. In your command line tool key in:
npm install -g n
Then you can install any number of Node.js versions to switch between. To be safe, I installed v10.16.0:
And made sure I also have the latest version available, of course:
To switch between the two, you type in
Enter, use the up/down arrow keys to choose a Node.js version, hit
Enter again, and voila! You just changed the Node.js version on your machine!
Not yet sure how nicely this plays with
brew, I originally installed Node.js with Homebrew (as one does) but I’m not super concerned.
I hope I don’t need this often, but if I do, I’ve got it now. 🙂