0

Thank you to anyone taking the time to help me. Let me start off by saying I'm very new to the coding world so I'm still trying to get my head around using terminal on a mac. So I have both jsnode and npm succesfully installed on my system. When I've installed browser-sync it seems to install fine. However, when I run browser-sync --version I get the following error.

Last login: Fri Jan 19 01:08:36 on ttys000
Marks-MacBook-Pro:~ Brent$ npm install -g browser-sync
/Users/Brent/.npm-global/bin/browser-sync -> /Users/Brent/.npm-global/lib/node_modules/browser-sync/dist/bin.js
+ browser-sync@2.23.5
updated 1 package in 6.436s
Marks-MacBook-Pro:~ Brent$ browser-sync --version
module.js:540
    throw err;
    ^

Error: Cannot find module 'dev-ip'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/browser-sync/dist/utils.js:3:13)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
Marks-MacBook-Pro:~ Brent$ 

Also I don't know if this helps but I will show the PATH (not that I know what that means but I'm trying to read up):

Marks-MacBook-Pro:~ Brent$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
Marks-MacBook-Pro:~ Brent$ 

Also, is there any harm in installing something that is already installed? As in, doesn't it just replace the files that already exist? The reason why I'm asking is that I have uninstalled/reinstalled jsnode and npm multiple times to the point where I feel like I might just need to try and uninstall everything again and try a new method. Just to reiterate, my main question is how to get browser-sync to install properly! Thank you.

1 Answers1

2

I finally resolved this issue by using node version manager (nvm) instead of installing nodejs straight up. Here is a step by step guide to isntall nvm:

1.Completely uninstall nodejs. Use the terminal commands described here: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

The commands you need to use are highlighted in gray. Use either one of the top two commands (they are the same, as the OP describes) and then run the bottom command he lists as well.

  1. Install Nodejs through NVM as described in STEP 0 of this blog: http://nodesource.com/blog/installing-node-js-tutorial-using-nvm-on-mac-os-x-and-ubuntu/ Basically he isntructs you to run a few command in the terminals. Note that you do not need to install the LTS versions (I don-t even know what they do), unless you want to.

  2. Verify that NVM was installed properly. Skip to STEP 3 of the above blog.

4.Refresh the terminal (open and close it) and then use the command "nvm use node" It will spit out the node version you are using.

  1. Install browser-sync using the "npm install -g browser-sync" command

  2. Verify that browser-sync installed using "browser-sync --version" command