20

Quick question, when I run browserify index.js -o app.js from mac terminal, I get command not found. I have done npm install -g browserify but still no luck. Any idea why I am getting this?

Thank you

It was easier for me to do a gist than to paste here: https://gist.github.com/pertrai1/4ccf77e7b31cb5628b5d

pertrai1
  • 3,866
  • 10
  • 41
  • 68

6 Answers6

16

Just install it in a global space like this if you need to run it from the command line.

npm install browserify -g

You may need to run

npm uninstall browserify -g fist just to be sure you don't have false aliases.

prosti
  • 35,325
  • 9
  • 162
  • 139
7

Add this to your ~/.bashrc or equivalent:

export PATH=$PATH:~/.npm-global/bin/

Then, to actually have this take effect in your terminal session, execute source ~/.bashrc.

At this point you can execute browserify, as well as potentially many other commands. Check out ~/.npm-global/bin/ to see what's become available.

jjpe
  • 654
  • 4
  • 13
1

I could not get browserify to work either.

Running ~/.npm/bin/browserify does work.

Other packages seem to run fine (phantomjs for instance).

A workaround fix seems to be adding alias browserify='~/.npm/bin/browserify' to your .bash_profile

Mogsdad
  • 42,835
  • 20
  • 145
  • 262
Janvdm
  • 11
  • 1
0

If for some reason the browserify command has not been installed at all (can happen for example if you're running Homebrew on old unsupported Mac OS X versions), an alternative is to call it via node, for example:

export NODE_PATH=/usr/local/share/npm/lib/node_modules
node -e 'require("browserify")("input.js").bundle().pipe(fs.createWriteStream("output.js"))'
Silas S. Brown
  • 1,304
  • 1
  • 15
  • 17
0

It is an old post but I believe people are still facing the same problem, like me.

This was how I solved my problem:

<your project folder>/node_modules/browserify/bin/cmd.js main.js -o bundle.js
0

As a Mac user I had to add

export PATH=$PATH:/usr/local/Cellar/node/13.6.0/bin/

in ~.bash_profile

Why Cellar path i dont know.

luky
  • 2,057
  • 3
  • 18
  • 31