Can't Install Browser Sync on Mac - browser-sync

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.

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.
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.
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.
Install browser-sync using the "npm install -g browser-sync" command
Verify that browser-sync installed using "browser-sync --version" command

Related

npm giving error on Mac Big Sur, not able to install or run

I just installed node with the below commands and here are the outputs
$ brew install node
$ node -v
v9.4.0
$ command -v node
/usr/local/bin/node
$ ls -l /usr/local/bin/node
-rwxr-xr-x 1 icyborg wheel 35697312 Jan 14 2018 /usr/local/bin/node
after running
$ brew upgrade node
Warning: node 15.9.0 already installed
but when I do
$ node -v
v9.4.0
now when I am trying to do
npm -v
It gives this error,
TypeError: Cannot destructure property `stat` of 'undefined' or 'null'.
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/#npmcli/node-gyp/lib/index.js:2:29)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/#npmcli/run-script/lib/run-script-pkg.js:4:55)
at Module._compile (module.js:660:30)
/usr/local/lib/node_modules/npm/node_modules/#npmcli/config/lib/index.js:163
throw new Error('call config.load() before reading values')
^
It is difficult to understand this error. May I know what can be the issue? I thought npm comes with node and I can't find any way to install it independently on mac.
SOLUTION - it seems node wasn't LinkedIn. I ran
brew link --overwrite node
and it is working now
Node.js 9 has been unsupported for about 3 years. The error you're seeing is very likely due to using an old Node.js with a new npm.
When I run brew info node, it says 15.2.0 is available. So, either something went wrong with your brew installation, or else you have an old version of Node.js somewhere else in your path (or as an alias) that runs instead of the version installed by brew.
Run command -v node to find out what Node.js is being executed. If it doesn't start with /usr/local/bin/node, then that's your problem. If it is /usr/local/bin/node, run ls -l /usr/local/bin/node to make sure it's a link to something in /usr/local/Cellar/node. If it's not, that's your problem... (EDIT #2: ...and as OP notes in a comment, brew link --overwrite node fixed that for them. So anyone else reading this can try that.)
EDIT #1: Since you've updated the question with the above information: It looks like you probably installed Node.js 9 around 3 years ago with the regular installer and not brew. Again, you can probably avoid all these headaches by uninstalling with brew and reinstalling with nvm as mentioned in the next paragraph.
In general, if you're installing Node.js on a personal computer and not on a server, I'd recommend uninstalling the brew version and installing with a per-user version manager. nvm is a solid choice:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

Error running npm command on Windows: graceful-fs

I have a ReactJS project and I was trying to use some of the PrimeReact components. At some point, I faced an error (can't remember exactly which one) and I tried to run an older version of NPM in a copy of my main directory.
Now, I get this error every time, even when I run npm command.
I've already tried to delete my node_modules folder, delete my project and clone it back from GitHub and also to reinstall NodeJS several times. I don't know what to do!
I have Windows 10 and I'm using NodeJS v12.16.0.
Thanks to anyone that offers some help
Update: I have never installed gulp. I suppose that maybe some dependency is using it but, because I can't run any npm command, I can't remove them D:
The error:
C:\Users\Carlos>npm
evalmachine.<anonymous>:35
} = primordials;
^
ReferenceError: primordials is not defined
at evalmachine.<anonymous>:35:5
at Object.<anonymous> (C:\Users\Carlos\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\node_modules\graceful-fs\fs.js:12:1)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
at Module.load (internal/modules/cjs/loader.js:1001:32)
at Function.Module._load (internal/modules/cjs/loader.js:900:14)
at Module.require (internal/modules/cjs/loader.js:1043:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\Carlos\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-client\node_modules\graceful-fs\graceful-fs.js:3:27)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
It might be an error related with gulp and node v12 conflict. If you have the gulp installed globally in your environment and you can uninstall without problems, you can try it. To help with commands, check if you have the gulp installed, typing this in your command line interface:
gulp -v
Uninstall your version:
npm uninstall -g gulp

Node - Difference between npm -v and the real version

Using Mac terminal and trying to run a Gatsby site, I am running into a problem.
As far as I found out, it is becase of an old version of Node. Particularly, "Node 6.* doesn't natively support async operations".
Just out for curiosity, the error I get when installing the app is:
async sendEvents() {
^^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/lib/index.js:3:19)
So it looks like a matter of just upgrading.
Here comes the tricky part.
When I run npm -v, I get this output: 6.12.0. Ok, all looks coherent. I get the error because I have version 6.
Then I go brew upgrade npm and check out the output: Error: npm 12.11.1 already installed.
Any comments?
I think you should get the latest stable version of node instead ([Download Node])1, because the brew upgrade npm command only upgrades npm. When you download the .dmg file for Node, you get the latest stable version for Node and NPM.
Then, the npm -v just returns the version of npm you currently have installed on your machine and the real version (will assume node -v) is the version of node js running on your machine.
NPM is the Node Package Manager. It is not the same as Node itself. To get the current version of Node that's running, node -v will tell you.
Node and npm are individual modules if you will. You do get npm installed with NodeJS, But they can be installed separately as well.
So you can end up with two different versions of each.
In addition, you can have node and npm installed locally. Or you could have node and npm installed with homebrew. (in a cellar) In which case you end up with two separate installs. So you may need to check which install is being actively used.
In your case, check what node version you have first.
node --version
and then you can go from there. If it matches npm version, check what path is linked when you type npm or node.
You may potentially use which command to see which installation is currently being used.
which node
above command should give you path, copy that path
and run
ls -l [copied-path]
output from ls -l should give you a path that will tell you which installation is being used.
If above path does not point to brew path, I believe you can run brew link to change that path
brew link node

NodeJS error when trying to run Polymer CLI

I get the following error running the polymer cli.
$ polymer
module.js:327
throw err;
^
Error: Cannot find module '..'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at /usr/local/lib/node_modules/polymer-cli/bin/polymer.js:19:36
at /usr/local/lib/node_modules/polymer-cli/node_modules/resolve/lib/async.js:46:14
at process (/usr/local/lib/node_modules/polymer-cli/node_modules/resolve/lib/async.js:173:43)
at ondir (/usr/local/lib/node_modules/polymer-cli/node_modules/resolve/lib/async.js:188:17)
at load (/usr/local/lib/node_modules/polymer-cli/node_modules/resolve/lib/async.js:69:43)
at onex (/usr/local/lib/node_modules/polymer-cli/node_modules/resolve/lib/async.js:92:31)
I've tried node 4.x and 6.x
I've also tried to install different versions of polymer-cli, 0.8 and 0.10
I'm running node on Ubuntu 16.04.
Does anyone know what issue I'm running into or how I can resolve this?
Ok wow after quite a lot of digging and searching, I found the answer. Turns out I had previously tried to install polymer-cli using the default ubuntu package. This installed it in a separate location, also on the global path.
When I remove NodeJS and NPM to install the latest version via the PPA, the original polymer-cli was still left on my path. So when I then installed the latest polymer-cli, this was correctly installed, but was never the one being executed since the old one was found on the path first.
I manually deleted all node_modules folders and after doing that I was able to install and run the correct version of polymer-cli, and it now works perfectly fine.

What's wrong with my typescript compiler? `tsc --version` returns nothing

In Linux Mint, I've installed node and used it to install typescript. With a working typescript installation, tsc --version should return the version number. In my case, nothing is returned at all.
When I run which tsc the result is /usr/local/bin/tsc.
When I run cat /usr/local/bin/tsc the result is:
#!/usr/bin/env node
require('../lib/tsc.js')
When I run find /usr/local -name 'tsc*' the result is:
/usr/local/bin/tsc
/usr/local/lib/node_modules/typescript/bin/tsc
/usr/local/lib/node_modules/typescript/lib/tsc.js
Does that look correct? If so, then any ideas on what else to look at would be appreciated?
Note I also tried running /usr/local/lib/node_modules/typescript/bin/tsc --version and got the same result ie nothing.
In my case on Ubuntu 16.04 the problem was because of I performed sudo apt-get install node-typescript, which delivered me broken tsc. After removing it via apt-get remove and then installing as recommended with npm install -g typescript, it worked fine.
Maybe this will help someone.
I discovered that running node --version returns nothing (but shouldn't) however nodejs --version works (the result being v0.10.25). Reinstalling node didn't fix this. I don't know why this would be the case, as I think I followed the recommended installation procedure.
However, editing file /usr/local/bin/tsc and changing the line:
#!/usr/bin/env node
to
#!/usr/bin/env nodejs
seemed to work. Now tsc --version returns message TS6029: Version 1.6.2 and I'm getting .js files generated when I run make.
I was getting the following error in Ubuntu 16.04.6 :
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'typescript/tsc.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/bin/tsc:2:1)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Running : npm install -g typescript didn't resolved the issue.
So, I had to install the latest version of node i.e nvm install <nvm version>
Then with npm install , it fixed the issue.

Resources