If you must update node

Creating this post for anyone that had to update node and ran into issues in their existing sage projects. (i.e. I updated node since I just had to play with phoenix/elixir). Just some quick fixes:

1 - If you’re getting these errors it stems from an incompatibility with npm and later node versions, so we must update npm:

Delete your current ~/.npm folder rm -rf ~/.npm
Install latest NPM: npm install -g npm@latest
May need to: sudo chown -R $(whoami) /usr/local/lib/node_modules/
Delete your current sage/node_modules folder
run npm install from sage directory again

Side note: having upgraded from a 0.12 version of node, the gulp build process SEEMS faster, unfortunately I’m unwilling to confirm at this time. :slight_smile:
Side note 2: there is a new progress bar on npm, woo.

2 - With the latest node (6.5, apparently anything above 5.5) you’ll run into this issue where gulp mistakenly looks for LESS files instead of SASS files: Compiling new scss, error .less not found - #8 by jasperfrumau | https://github.com/roots/sage/issues/1648

Assuming you use SASS, this is a problem. You can fix this on a per-project basis by commenting out these lines in your gulp file:

.pipe(function() {
    return gulpif('*.less', less());
})

OR you can update gulp-if to this version in your package.json file:
"gulp-if": "^2.0.1",
then run:
npm update in your sage directory

2 Likes

Please just use nvm as recommended in Npm Debugging Guidelines (Failed npm install, bower install, or gulp build? Read this) - #4 by austin

I would not use nvm, I would go with n instead. Stupid easy, no-fuss.

Can get started with n over here.

2 Likes

I can’t comment on nvm because I haven’t used it, but n is definitely the business.

I was messing around with Ghost, or Jekyll or something about a year ago and I needed a newer node version. Then my Sage projects wouldn’t compile and in trying to sort things out I ended up screwing up my whole setup. That was when I discovered n. Not had a problem since.

Wow, that felt like a commercial… but it’s true - n is super nice. :slight_smile:

2 Likes

NVM did give me some trouble but it’s been so long I don’t recall what the issue was. Most assuredly something I was doing wrong as I was new to command line tools at that time.

@loffelmacher thanks for the link to n, sounds nice.

2 Likes