javascript 未找到 Browserify 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24947262/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Browserify command not found
提问by pertrai1
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?
快速提问,当我从 mac 终端运行 browserify index.js -o app.js 时,我找不到命令。我已经完成 npm install -g browserify 但仍然没有运气。知道为什么我会得到这个吗?
Thank you
谢谢
It was easier for me to do a gist than to paste here: https://gist.github.com/pertrai1/4ccf77e7b31cb5628b5d
对我来说,做一个要点比在这里粘贴更容易:https: //gist.github.com/pertrai1/4ccf77e7b31cb5628b5d
回答by prosti
Just install it in a global space like this if you need to run it from the command line.
如果您需要从命令行运行它,只需将它安装在这样的全局空间中。
npm install browserify -g
npm install browserify -g
You may need to run
你可能需要运行
npm uninstall browserify -gfist just to be sure you don't have false aliases.
npm uninstall browserify -g拳头只是为了确保你没有假别名。
回答by jjpe
Add this to your ~/.bashrcor equivalent:
将此添加到您的~/.bashrc或等效的:
export PATH=$PATH:~/.npm-global/bin/
export PATH=$PATH:~/.npm-global/bin/
Then, to actually have this take effect in your terminal session, execute source ~/.bashrc.
然后,要在终端会话中实际生效,请执行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.
此时,您可以执行browserify以及许多其他可能的命令。看看~/.npm-global/bin/,看看有什么可用。
回答by Janvdm
I could not get browserifyto work either.
我也无法browserify上班。
Running ~/.npm/bin/browserifydoes work.
跑步~/.npm/bin/browserify确实有效。
Other packages seem to run fine (phantomjs for instance).
其他软件包似乎运行良好(例如 phantomjs)。
A workaround fix seems to be adding alias browserify='~/.npm/bin/browserify'to your .bash_profile
解决方法修复似乎正在添加alias browserify='~/.npm/bin/browserify'到您的.bash_profile
回答by Silas S. Brown
If for some reason the browserifycommand 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:
如果由于某种原因browserify根本没有安装该命令(例如,如果您在旧的不受支持的 Mac OS X 版本上运行 Homebrew,则可能会发生这种情况),另一种方法是通过调用它node,例如:
export NODE_PATH=/usr/local/share/npm/lib/node_modules
node -e 'require("browserify")("input.js").bundle().pipe(fs.createWriteStream("output.js"))'
回答by VeryNiceArgumentException
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
回答by luky
As a Mac user I had to add
作为 Mac 用户,我必须添加
export PATH=$PATH:/usr/local/Cellar/node/13.6.0/bin/
in ~.bash_profile
Why Cellar path i dont know.
为什么地窖路径我不知道。

