How to include npm in node install

(Mike Frawley) #1

tldr; AFAIK the node formula opts out of the bundled npm and has code to install npm itself, but it defaults to not install it and has no option to override that.

After brew update, I ran:

brew reinstall node
==> Reinstalling node --without-npm
==> Downloading
Already downloaded: /Users/mfrawley/Library/Caches/Homebrew/downloads/86b0da83f0376473debf56a6f68f0a3cca0ae8d439da5e3128ce912d9069b215--node-v10.11.0.tar.xz
==> ./configure --prefix=/usr/local/Cellar/node/10.11.0 --without-npm --with-intl=system-icu
==> make install
==> Caveats
Homebrew has NOT installed npm. If you later install it, you should supplement
your NODE_PATH with the npm module folder:
==> Summary
🍺  /usr/local/Cellar/node/10.11.0: 325 files, 30MB, built in 17 minutes 17 seconds

As you can see, it didn’t install npm. Only instance of that binary is from a previous install using the nvm tool:

whence npm

Looking at the formula, I see there is a --without-npm option:

I also see that from the cli:

brew options node
	Build against Homebrew's OpenSSL instead of the bundled OpenSSL
	Build with small-icu (English only) instead of system-icu (all locales)
	npm will not be installed
	Install HEAD version

However, from the install output above, you can see it ran --without-npm even though I didn’t pass that. I see in the formula option is always added:

I tried different combinations of adding args like --with-npm, --without-npm=false, --with=npm but I get:

brew reinstall node --with-npm
==> Reinstalling node --without-npm
Warning: node: this formula has no --with-npm option so it will be ignored!

I haven’t found a good way to install npm standalone, so just going to install node through the official download for now.

Any ideas?

(Sean Molenaar) #2

It seems you’re confusing the node compile arguments with homebrew arguments. The line you highlighted always excludes NPM from node. The homebrew argument controls if the resource "npm" do above that should be used to install npm anyway.

The brew command however mentions that ==> Reinstalling node --without-npm you did install it explicitly without NPM in homebrew. This you can fix by uninstalling node completely and installing it just using brew install node

(Mike Frawley) #3

Heh yea, I was suspecting those two uses of --without-npm in the formula were different. However I’m still confused because at no point did I use the --without-npm argument yesterday when trying brew install/upgrade/reinstall node so I’m not sure where its coming from.

I just saw I had some old versions which I removed:

node 5.9.1, 6.3.1, 7.4.0, 0.12.0_1, 6.1.0, 8.4.0, 5.8.0, 6.2.1, 7.2.1 9 are still installed

The only thing I can think of is that perhaps I installed one of them with --without-npm way back when, and that brew persists that option and automatically adds it on future installs/upgrades/reinstalls. Do you know if thats the case?

I installed npm via downloaded the official .pkg yesterday so brew install node is not able to complete due to an error in the linking stage. Don’t really want to mess with that to test if removing all nodes and installing would work, unfortunately :’(

Thanks for you help.

(Sean Molenaar) #4

If node updates from 1 to 2 it’s still the same formula so if you installed it with an option then it’ll still have that option now.