BrowserSync : Command not found after installing browser-sync
Asked Answered
M

3

15

There was another issue open with the same title which has been closed but my error could not be resolved using the solutions given in that issue.

  • Mac OSX El Capitan
  • Node [v5.6.0]
  • Npm [v3.6.0]

I installed Browser-Sync successfully using : bash $ sudo npm install -g browser-sync

but when I check the browser-sync version by typing : bash $ browser-sync --version

I get this error : bash -bash: browser-sync: command not found

Manda answered 19/2, 2016 at 7:57 Comment(6)
How did you install node and npm? Can you please post your PATH environment variable?Lengthways
@Lengthways : Here is my $PATH : screen shot 2016-02-19 at 11 19 43 pmManda
Please run npm bin -gLengthways
@Lengthways : ScreenshotManda
You wrote export PATH=~/Users/islahul/.npm-packages/bin:$PATH. Try this export PATH=/Users/islahul/.npm-packages/bin:$PATHLengthways
Works awesome now! Screenshot After soo many days of trying, I can't thank you enough for walking me through this!Manda
L
19

Check where npm installs it's binaries by running npm bin -g, and then add that to your PATH.

export PATH=$PATH:/usr/local/bin
Lengthways answered 19/2, 2016 at 8:24 Comment(3)
Is this correct? screen shot 2016-02-19 at 11 34 08 pm If yes, I am still not being able to access browser-sync. Please help.Manda
@FaheemHassanZunjani export PATH=/Users/islahul/.npm-packages:$PATH Just remove the tilde characterMakalu
@Lengthways I've been stuck on this for hours. Best Answer. Thank you.Etherify
P
6

None of this was helpful to me, instead what I did was find the file location of browser sync after i executed the browser-sync download command supplied on their website. npm install -g browser-sync

Turns out my windows 10 put that downloaded file into %appdata% folder which is in Local Disk (C), but it's an invisible folder and not the correct place it should be, it needs to be in the nodejs folder inside Program Files...

So to find this folder do this: in the search bar of windows 10 type in %appdata% and press Enter, it should open up that hidden folder...

Then click on npm > npm_modules > then you should see files saying browser-sync. Highlight and drag all those files into Local Disk (C) > Program Files > nodejs. You will get allow access prompts, just allow all those.

Now browser-sync and nodejs are sitting happily together and NOW, you can go back to your CMD window and type in browser-sync --version and get the correct version.

I am taking the Coursera class titled HTMl, CSS, and Javascript for Web Developers and ran into this very problem and this solution made it possible for me to continue setting up my environment to take the class.

Petiole answered 26/8, 2020 at 18:55 Comment(0)
P
0

Although above answers are correct, there is an easy way to handle this. Instead of explicitly creating $PATH we can install Browsersync globally.

npm i -D browser-sync

Here -g option specifies npm to install browser-sync package globally and add $PATH automatically. Next check wether it is working or not by running:

browser-sync --version

Note: Even if you already installed Browsersync try running this. The issue will be resolved.

Partial answered 5/10, 2022 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.