Gatsby: Suggest people install Node.js w/ Homebrew (on macs)?

Created on 11 Dec 2018  ·  20Comments  ·  Source: gatsbyjs/gatsby

Something we've heard quite a few times is that installing Node.js on macs can be difficult for people new to the Node world e.g. there's frequently problems with permissions which can be very confusing and a major roadblock.

I always use Homebrew to install dev tools which takes care of things like this.

What do people think about suggesting people use Homebrew for installing Node on Macs for Gatsby?

/cc @gatsbyjs/docs @gatsbyjs/core

help wanted documentation

Most helpful comment

@KyleAMathews and @m-allanson if you don't mind my two cents, but adding homebrew and Xcode's Command Line Tools, and with that adding another step to the install process, might look like somewhat of a hassle beforehand, but further down the line it will avoid some issues inbound to here. As much as gatsby tends to be a "turn key" solution, as you add it and you're quasi good to go to start hammering the keyboard and pushing out apps, content or what the person is going to use gatsby for.
Without this preventive measure, let's call it that, people will start flooding the issues, asking about what's happening and how to solve it and what is this error. I'm saying this based on recent issues that have spawned here. But again this is just my two cents

All 20 comments

I prefer https://github.com/creationix/nvm because

  • works on Linux and macOS (so might be a better and more general recommendation)
  • the ease of switching between versions etc

However, Homebrew is much simpler and probably a better recommendation for someone new to Node and if Mac only

Both homebrew and nvm require XCode's Command Line Tools which adds another step to the install. But that is probably simpler than dealing with permissions issues after using the official node installer.

I've done this in the past:

  • Install XCode CLI tools
  • Install node installer installer (homebrew)
  • Install node installer (nvm)
  • Install node

Which is great once it's done but does seem a bit silly. You could easily drop one of homebrew or nvm just for getting started.

@KyleAMathews and @m-allanson if you don't mind my two cents, but adding homebrew and Xcode's Command Line Tools, and with that adding another step to the install process, might look like somewhat of a hassle beforehand, but further down the line it will avoid some issues inbound to here. As much as gatsby tends to be a "turn key" solution, as you add it and you're quasi good to go to start hammering the keyboard and pushing out apps, content or what the person is going to use gatsby for.
Without this preventive measure, let's call it that, people will start flooding the issues, asking about what's happening and how to solve it and what is this error. I'm saying this based on recent issues that have spawned here. But again this is just my two cents

From about 4 usability tests with Mac users and the tutorial, Macs prompt
users to install Xcode when they download VSCode anyway. So there might not
be a way for Mac users to avoid installing Xcode, though being prompted by
their operating system and clicking an "ok" button is a little easier than
installing it themselves.

On Tue, Dec 11, 2018 at 8:51 AM jonniebigodes notifications@github.com
wrote:

@KyleAMathews https://github.com/KyleAMathews and @m-allanson
https://github.com/m-allanson if you don't mind my two cents, but
adding homebrew and Xcode's Command Line Tools, and with that adding
another step to the install process, might look like somewhat of a hassle
beforehand, but further down the line it will avoid some issues inbound to
here. As much as gatsby tends to be a "turn key" solution, as you add it
and you're quasi good to go to start hammering the keyboard and pushing out
apps, content or what the person is going to use gatsby for.
Without this preventive measure, let's call it that, people will start
flooding the issues, asking about what's happening and how to solve it and
what is this error. I'm saying this based on recent issues that have
spawned here. But again this is just my two cents


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/10398#issuecomment-446275398,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ae9o2jOB6AaN_J0J03ccAELfWGlnWGpxks5u3-KFgaJpZM4ZMiQE
.

I agree with what @jonniebigodes says -- In my experiences helping new learners (youth and educators new to command line) installing node via Homebrew on Mac saves lots of time in the future. Ever since I had to help troubleshoot a whole classroom full of permission issues I just have them go through the extra steps from the very beginning, including installing Homebrew itself. This also seems to bypass any issues with needing to use sudo for any npm installs.

My process for walking new learners:

  1. have them open terminal and see if Homebrew is installed
  2. If not, show them how to install it via the link on https://brew.sh/
  3. Show them how to use brew to install node, and if prompted, Xcode Command Line Tools

In my experience having folks start from this common ground helps with troubleshooting since I know that node has been installed the same way for everyone.

I agree with the consensus that helping people install node via home-brew on Macs is the way to go. I used to teach code, and we would have a group of about 20 people (all new to code) install node and other dev tools together. Though there definitely were individual cases where permissions issues or other problems came up, most of those were due to people already having played around with downloading dev tools without knowing what they were or how they would interact. In my experience, if you can get a person set up with homebrew and Xcode and all that early, it gives them a good platform to continue adding other tools.

If its helpful, I still have the instructions we would give out for installing home-brew and a few other things, it might be a fast base document that we could edit.

It sounds like using homebrew is the strong consensus here, I think it makes sense to go with that.

If its helpful, I still have the instructions we would give out for installing home-brew and a few other things, it might be a fast base document that we could edit.

@berkeleycole that would be amazing, thank you!

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! 💪💜

@marcysutton you want to look into this? It seems to me like a really solid improvement. A lot of people run into problems getting node installed directly from nodejs.org

@KyleAMathews I think the latest version of Homebrew supports Windows too (in beta!).

So if we do choose to roll this out, it _could_ be an improvement on non-Mac OS'es as well.

https://brew.sh/2019/01/09/homebrew-1.9.0/

That's really awesome news about Homebrew! I was actually thinking about this earlier today -- I was thinking about writing up some of my notes and walkthrough for getting new learners set up from scratch with Homebrew and Node. I was helping a few people lately with getting up and running with Node based things and realized that so much of my notes are Mac-centric because that's what we use at our learning space.

I was then thinking about how to make my notes on the process more universal and this is great to hear!

This is usually where beginners get stuck on the Gatsby tutorial - when
their mac throws an error bc they have to enter their password in order to
install Node, and terminal isn't clear about how to do that. The
instructions we linked to are a stop-gap and are still hard to do for
beginners.

On Thu, Feb 21, 2019 at 1:45 PM Jonathan Prozzi notifications@github.com
wrote:

That's really awesome news about Homebrew! I was actually thinking about
this earlier today -- I was thinking about writing up some of my notes and
walkthrough for getting new learners set up from scratch with Homebrew and
Node. I was helping a few people lately with getting up and running with
Node based things and realized that so much of my notes are Mac-centric
because that's what we use at our learning space.

I was then thinking about how to make my notes on the process more
universal and this is great to hear!


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/10398#issuecomment-466179427,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ae9o2mSLghaw_VYEy_mcFzWg3OrA4Wq0ks5vPxOEgaJpZM4ZMiQE
.

would videos help here? https://www.gatsbyjs.org/tutorial/part-zero/#create-a-gatsby-site

we could make a video for homebrew on mac osx and see if it helps them if not then try it too with our current approach (visiting nodejs website).

Perhaps create pages for each operating system. Homebrew is amazing.

Short videos would be incredible.

I suspect getting Node installed correctly is _the_ biggest hurdle for new people to Node trying to use Gatsby.

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

Run the following commands to remove all existing global npm modules, uninstall node & npm, re-install node with the correct defaults, configure the location for global npm modules to be installed, and then install npm as its own pacakge.

rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh

Node and npm should be correctly installed at this point. The final step is to add ~/.npm-packages/bin to your PATH so npm and global npm packages are usable. To do this, add the following line to your ~/.bash_profile:

export PATH="$HOME/.npm-packages/bin:$PATH"

Now you can re-install any global npm packages you need without any problems.

Homebrew also works on Windows now, as well--so this seems especially worth doing if we can validate it works well on Unix and Windows.

For first-time node users getting started quickly, it might not be necessary to have multiple node versions installed, however I always recommend that developers use nvm. @sidharthachatterjee mentioned this above in https://github.com/gatsbyjs/gatsby/issues/10398#issuecomment-446231837.

Would it be worth documenting nvm as an alternative?

Hi everyone, there is a PR open that adds Homebrew instructions to the Tutorial: https://github.com/gatsbyjs/gatsby/pull/13051 Now would be a great time to chime in on accuracy, gotchas, etc.

In discussing this with @jlengstorf, we decided it's important to keep this simple...there are too many variations/edge cases for us to document every setup. Even videos, while a cool idea, are likely to get out of date and introduce scope creep for the Gatsby docs. It's better to link off to other resources rather than try to maintain everything ourselves.

As for including nvm, consider the audience of the Tutorial. Part 0 is where Node.js setup is documented. While the Tutorial is useful for all skill levels, it's intended to be streamlined with as few steps as possible. I don't think managing multiple Node versions is in scope for the Tutorial, and therefore I'd recommend against it there. Perhaps we could link to Node management resources from another part of the docs instead?

Related: I got a question the other day about whether nvm was necessary for building a Gatsby site, where the user wasn't sure how to upgrade. I've personally found n to be less frustrating than nvm, but the bigger question here is around documenting Node.js upgrades. We should go just far enough to help Gatsby devs find success, but avoid documenting too much outside of Gatsby-specific stuff. Feedback is welcome on how to solve this problem as I think through it further...it seems like a Node.js upgrade across the board is potentially easier than introducing version management.

while the tutorials seem straightforward, I have a feeling that something about my nvm/npm node setup and access to dependencies is a bit wonky - or I’m getting warnings about dependencies in the gatsby-starter where the complaint is because of a newer rather than outdated version of whatever the installer is looking for.

Appreciate your explaining your reasoning about the audience! It's really helpful for thinking about this. I agree that it's upgrading to the latest node, and not actually running two node versions, that is a more fundamental need. 👍

So it turns out this was only simpler for Mac users–we weren't considerate enough of Windows, and having to install Windows Subsystem for Linux and Homebrew seems like overkill for users who don't already have that set up (my own Windows 10 machine is stuck on a patchelf issue when installing Node in Ubuntu and I'm not really sure how to fix it).

I'm recommending we revise the tutorial step 0 and Gatsby on Windows guide to recommend installing from Nodejs.org instead of Homebrew. If anyone has input on that (or for Linux distros), feel free to comment over in #15529.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hobochild picture hobochild  ·  3Comments

totsteps picture totsteps  ·  3Comments

timbrandin picture timbrandin  ·  3Comments

3CordGuy picture 3CordGuy  ·  3Comments

ferMartz picture ferMartz  ·  3Comments