5

I've installed node on my macOS

brew install node

After doing this, node is installed correctly:

$ node -v
  v8.4.0

But running

$ npm -v

gives me -bash: /usr/local/bin/npm: No such file or directory

What would be the way now to install node with npm via brew?

brew install node uses by default --without-npm

fernandopasik
  • 9,565
  • 7
  • 48
  • 55
user3142695
  • 15,844
  • 47
  • 176
  • 332
  • What does `which -a npm` say? Does it work if you try it in a new terminal session? – bfontaine Aug 21 '17 at 09:02
  • Judging by the amount of issues posted here on SO caused by Homebrew-installs of Node.js, I would suggest using the official Node.js installer for macOS instead. – robertklep Sep 09 '17 at 11:06
  • @robertklep I'd recommend [NVM](https://github.com/creationix/nvm) personally. Used it widely on Mac OS and Linux and never had any problems with it. – Matthew Daly Sep 09 '17 at 11:12
  • @MatthewDaly I use `nvm` as well, but also have a "global" Node.js installation (and nvm's "default" pointing to it). – robertklep Sep 09 '17 at 11:13

3 Answers3

2

I had the same problem. I ran $ brew doctor to make sure node was linked first. Then I ran
$ brew postinstall node

$ npm -v should now show the version number.

XtalOsc
  • 71
  • 2
1

I stepped into a similar issue, too. My problem was that I still had not a ~/.bash_profile file in place and therefore no place where to actually link my bash command to npm.

Andrea Carraro
  • 9,731
  • 5
  • 33
  • 57
0

Don't use Homebrew to install node.

I like the Node Version Manager (NVM), and there is n. These are better options on a Mac for node, to avoid certain. issues. later. Plus it avoids this question, as these node versions include npm.

Note, you can install nvm and n via Homebrew. (brew install nvm or brew install n).

clay
  • 5,917
  • 2
  • 23
  • 21