27

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

3
  • Hey, I am on unix and tried both with still no luck :-( Commented Jul 25, 2014 at 2:53
  • 2
    can you paste the console log when you rerun npm install -g browserify? Commented Jul 25, 2014 at 2:53
  • So you should have a binding /Users/robsimpson/npm/bin/browserify -> /Users/robsimpson/npm/lib/node_modules/browserify/bin/cmd.js now. Does /Users/robsimpson/npm/bin/browserify work when you try to run it? Commented Jul 25, 2014 at 3:12

9 Answers 9

19

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.

Sign up to request clarification or add additional context in comments.

5 Comments

This is necessary but not sufficient, since that will still not add the command to your PATH. See my answer.
I see, sorry, I was not reading the whole thread, but this must work, eventually.
No need for apologies, nobody can know everything :)
Worked for me, since it's often used globally I forgot to put it in my dev-dependencies
Works for me. Be sure to run npm uninstall browserify -g then npm install browserify -g
9

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.

Comments

2

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

Comments

2

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 

Comments

1

If you install locally npm install browserify, you can use this method to execute the browserify command.

node_modules/.bin/browserify

For example: broweserify command example

Extra tips:

Add this command to your packages.js file:

... "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "bundle": "node_modules/.bin/browserify index.js > bundle.js" }, 

Then everytime you want to bundle you file just hit npm run bundle

Hope it helps you guys out there..

Comments

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"))' 

Comments

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.

Comments

0

I'm using the default zsh shell and I came across a solution: sudo npm install browserify -g

After that sudo browserify AND browserify worked flawlessly. I guess mine was a simple permissions issue.

I'm running Ventura.

1 Comment

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
0

This is my solution to solve it within project directory, not by global

npm install browserify npx browserify main.js -o bundle.js 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.