Browser-sync is installed but doesn't open website on sierra os x

It is very interesting that I get an error when using this command:
ottergram documents$ browser-sync -v
-bash: browser-sync: command not found

There is no error when i precede the command with “npm”:
ottergram documents$ npm browser-sync -v
3.10.10

I get an error when I start the webpage:
ottergram documents$ browser-sync start --server --browser “Google Chrome” --files “stylesheets/*.css, *.html”
-bash: browser-sync: command not found

But when I precede the start command with “npm” the error is more informative but still ng:
ottergram documents$ npm ottergram documents$ browser-sync start --server --browser “Google Chrome” --files "stylesheets/*.css, .html"
-bash: browser-sync: command not found
Usage: npm
where is one of:
** access, adduser, bin,
*
where is one of:
** access, adduser, bin,**
etc…

Here are the files in my ottergram folder:
ottergram documents$ ls
ottergram documents$ ls
img index.html npm-debug.log stylesheets

here is npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ ‘/usr/local/bin/node’,
1 verbose cli ‘/usr/local/bin/npm’,
1 verbose cli ‘start’,
1 verbose cli ‘browser-sync’ ]
2 info using npm@3.10.10
3 info using node@v6.10.0
4 verbose stack Error: ENOENT: no such file or directory, open '/Users/documents/front-end-dev-book/ottergram/package.json’
4 verbose stack at Error (native)
5 verbose cwd /Users/documents/front-end-dev-book/ottergram
6 error Darwin 16.4.0
7 error argv “/usr/local/bin/node” “/usr/local/bin/npm” “start” "browser-sync"
8 error node v6.10.0
9 error npm v3.10.10
10 error path /Users/documents/front-end-dev-book/ottergram/package.json
11 error code ENOENT
12 error errno -2
13 error syscall open
14 error enoent ENOENT: no such file or directory, open '/Users/documents/front-end-dev-book/ottergram/package.json’
15 error enoent ENOENT: no such file or directory, open '/Users/documents/front-end-dev-book/ottergram/package.json’
15 error enoent This is most likely not a problem with npm itself
15 error enoent and is related to npm not being able to find a file.
16 verbose exit [ -2, true ]

safari is my default browser but I have chrome installed too

i understand now that preceding the command with npm to get the version number works because npm holds the packages including browser-sync. but i cannot get the browser to run my web page using the command(s) on page 27

help please?

Hi @xcoasty, sounds like your $PATH env variable might not include global npm modules, or perhaps you didn’t install browser-sync with the global flag. Did you install browser-sync with the -g flag like this?

npm install -g browser-sync

The -g flag tells npm to install browser-sync as a global node module that will be available in the terminal. Try running that and then your browser-sync command again. If that doesn’t work, your $PATH doesn’t include global node modules and there’s another thing we can try.

Prefixing and running npm browser-sync is a very different command — npm has it’s own commands, like install, that it understands, so running npm browser-sync is gobbledygook to it :slight_smile:

yes i used npm install -g browser-sync. so can you tell me more about $path? i searched and the examples i found simply say $path as the file “path” but i assume i have to insert my folder names

thanks

Hi @xcoasty, $PATH is an “environment variable” in your terminal; it’s an array of directories where the terminal will search for commands it can run (like npm, node, or browser-sync). Try running echo $PATH in your terminal, what does it print out?