Node install error - node.js

Im trying to install node + npm using brew and keep getting the following:
$brew install node
Warning: node-0.10.33_1 already installed, it's just not linked
Any ideas whats going on and how to fix?

Try brew doctor that should give you some idea of what the problem is. Also, I strongly recommend not installing node directly using brew, but actually installing nvm through (brew install nvm)
nvm is the node version manager, which allows you to install different versions of node, and quickly swap between them.

I have the same problem.
but I try lots method (e.g. nvm, uninstall, brew doctor, blabla...), and decide use http://nodejs.org/ pkg instead.
it would install perfectly without homebrew.
but if you are so likely use homebrew, I have no idea about this.

I had this problem as well. It was due to part of a leftover installation from running and using the pkg installer from nodejs.org. Simply:
brew uninstall node
rm -rf /usr/local/include/node
brew install node
And you're good to go. You could probably get away with skipping the uninstall and just performing a brew link node, but I didn't try that.

Related

Homebrew/Node.js showing up though not installed

When I do find . -name "node*" from my root directory, I get:
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node_exporter.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/nodeenv.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node-sass.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node#14.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node#10.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/nodebrew.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node#12.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/nodenv.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node#16.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node-build.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node#18.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/nodejs
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/node#19
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/node.js
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks/nodeclipse.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks/nodebox.rb
./usr/local/Homebrew/Library/Homebrew/rubocops/cask/extend/node.rb
./usr/local/Homebrew/Library/Homebrew/test/language/node_spec.rb
./usr/local/Homebrew/Library/Homebrew/language/node.rb
but brew ls doesn't show node and node -v and npm show that the commands are not installed on PATH? What's going on here?
I went through the process of
I went through the process of removing all traces of Node and npm from my own installation as npm was corrupted (was mishandling vulnerabilities), and now want to install it using brew, or in some other way so all the errors with npm when attempting to npm install don't occur. Why does brew have node installed even though I didn't install it?
Those files are not NodeJS itself, but are the instructions that tell Homebrew how to install NodeJS. You can remove those formula (along with any others that are not being used) with brew cleanup.
Edit: You cannot actually remove the formulae since those are needed if you were to install it at a later point.

How to install node package on MacBook for Socket.IO?

I have downloaded Node from Here for MacBook. Now when I double click on package, it is giving me error.
Anyone knows about this ?
Or can you give me other way to install node on MacBook ?
It used be fine. But then I haven’t tried to download directly from their site for a while.
Since I have a need to install multiple versions of node and switch between them, I used nodenv installed via Homebrew. Another popular tool people use is nvm.
You can follow simple instruction at https://brew.sh/ to install Homebrew and you can install node by brew install node. If you want to be able to switch between versions, you can install nodenv by following Homebrew install steps at https://github.com/nodenv/nodenv/blob/master/README.md. Then install node by nodenv install 12.16.1

Changing from existing nodejs installation through apt to NVM

I am on Ubuntu 18.04 with existing NodeJS installed through apt.
(currently on version 9.11.1)
I want to uninstall this and switch to NVM without destroying other dependencies (like yarn) and preferrably my whole system. I need to do these cleanly and I don't want to risk missing a step. Can you please help me?
(nvm maintainer here)
You can install nvm on top of your system node, without losing anything (although node and npm themselves will be shadowed by the nvm-managed node).
Separately, you can run npm ls -g --depth=0 to get a list of your global modules, and then you can reinstall those after you've installed and activated an nvm-managed node.
If you installed yarn a different way than npm install -g yarn, then uninstalling your system node/npm shouldn't impact it.

Why is node-gyp rebuild failing on Mac OSX El Capitan

I recently bought a mac, which uses Mac OSX El Capitan v10.11.4. Installed node with homebrew, and am using node v6.2.2 and npm v3.9.5. I'm getting an error with bcrypt during npm install, which I believe derives from a node-gyp rebuild error. I also recently downloaded xcode-select(version 2343) and xcode(7.3.1) (in that order).
Here is the full error output after i run npm install:
https://gist.github.com/varunjayaraman/5734af617d616437cd5b3456b20bc503
Not sure what's going wrong. I come from linux land and do tend to be wary of not installing from source myself, so maybe that is the cause of these issues? Anyway, any advice would be super appreciated. I also saw this error springing up for others, but none of their solutions seemed to work (when i type xcode-select --print-path, I get /Applications/Xcode.app/Contents/Developer)
Anytime i upgrade OSX to newer version, I get the same issue.
Here is how i solve it every time:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
That's it. Now next time you do npm install or yarn it'll work.
PS: Sometimes you won't be able to install the command line tool through Xcode-select, for example if you are on beta.
In that case, you should be able to install it manually from here: https://developer.apple.com/download/more/
This one just bit me, too. There were a couple of different solutions, only one of which worked for me.
First, make sure you have the XCode command line tools installed, as they say on their npm page.
1) The simplest solution, which of course didn't work (though it looks like it did for some people), is to just delete the ~/.node-gyp directory. So might as well give that a shot, as well as deleting your node_modules dir and doing another npm install.
2) Try uninstalling node-gyp and re-installing:
sudo npm uninstall node-gyp -g
npm uninstall node-gyp
npm install
3) But what did the trick was a solution given in a node-gyp issue on github, where you have to install another version of node and do your npm install that way. It's easier than it sounds, but it's pretty gross:
sudo npm cache clean -f
sudo npm install -g n
sudo n 4.4.5
sudo npm install npm -g
sudo npm uninstall node-gyp -g
Then try running npm install.
Hope that helps!
If the node_modules cache was built with a recent version of Node, you may need to remove the cache, revert back and then reinstall the packages:
rm -rf node_modules
nvm use 6
npm install
I have a simple solution. If the xcode-sellect is installed try running
sudo xcode-select --reset
Same issue I had after upgrading macOS
Update brew
brew update
Update X-Code
xcode-select --install
If needed, you may have to reset the path to X-Code
xcode-select --switch /Applications/Xcode.app
xcode-select --switch /Library/Developer/CommandLineTools
For anyone who tried reinstalling Xcode tools yet the same issue persists.
You will have to go following file:
~/.node-gyp/<your_node_version_here>/include/node/common.gypi
Note: Make sure to change <you_node_version_here> to your node version like:
~/.node-gyp/16.13.1/include/node/common.gypi
You can find node version using
node -v
Inside search for key MACOSX_DEPLOYMENT_TARGET and change it's value to your current os version like mine is 11.3.1 and you will be good to go.
You can find version in
about this mac
option in drop down of mac logo
If you are using virtualenv for your python, you need to deactivate it or point npm to use the OS's own python 2 installation for node-gyp to work.
EDIT:
Had another encounter with the same bug a few days ago. This time around node-gyp was not at fault. Apparently the module I was installing has a dependency on a very old version of node-gyp (v1), independent of the system's version (v3.8), which my version of node (v10) no longer supports. Since I did not need that module anymore, I removed it. Alternatively, you may wish to upgrade/downgrade/replace the offending module, or upgrade/downgrade your node. For the OP's case, the offending module was bcrypt#0.8.5.
if you want to upgrade Node to 10 or above, you have to find dependencies out of date with Node 10 in package.json and upgrade these packages to newer stable version, then build (npm/yarn install).
Try looking at your python install.
I found a hint at the discussion here https://github.com/nodejs/node-gyp/issues/489#issuecomment-431447692.
My python on my MacBook Pro is managed by Homebrew which installs binaries to
/usr/local/bin
So I did the following in terminal:
>$: npm config set python /usr/local/bin/python
>$: rm -rf node_modules
>$: npm i
I had a similar issue.
A lot of folks have recommended that you install Xcode, and point xcode-select to the /Applications/Xcode.app/Contents/Developer. However, there is one more step.
That is to confirm that the /Applications/Xcode.app/Contents/Developer folder has SDK version corresponding to the MacOS version your actual computer is running on.
If it does not, go into /Library/Developer/CommandLineTools and copy that over.
I had a similar issue and running the commands below fixed it for me
Install xcode
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
You need to re-install XCode Tool in order to compile your codes in your machine:
* xcode-select -print-path
* sudo xcode-select --reset
* xcode-select -print-path
Here's the main link you can install it on MacOS:
https://github.com/nodejs/node-gyp/blob/main/macOS_Catalina.md

Install io.js and npm without node via Homebrew on OSX

As $title says, I want to install io.js with brew on Yosemite.
In my system there is no need for Node.js, and I want to avoid unnecessary programs.
But.. When I run brew install iojs I see it will be built with --without-npm option, and as the post-install text clarifies, it needs a patched npm.
Although I searched for the solution, the only thing that came across is how to run io.js and Node.js side-by-side, and that's not what I'm looking for.
I see there is an npm package for brew, but it's part of the node package.
How can I install iojs+npm without node?
Install nvm (node version manager) using brew:
brew update
brew install nvm
source $(brew --prefix nvm)/nvm.sh
Add the last command to the .profile, .bashrc or .zshrc file to not run it again on every terminal start. So for example to add it to the .profile run:
echo "source $(brew --prefix nvm)/nvm.sh" >> ~/.profile
Using nvm you can install any version of node or io.js you want. So to install the latest version of iojs do:
nvm install iojs
npm is shipping with iojs so you don't need to install it manually.
Related question: What is the suggested way to install brew, node.js, io.js, nvm, npm on OS X?
I've had the same problem: homebrew doesn't seem to properly explain how to get that "patched" npm in a clean way.
Anyway, nothing has worked for me better than getting that pkg from iojs.org, which includes npm.
(I'm referring to iojs v2.0.0)
It might be late but you can just use brew unlink node && brew link iojs --force
I avoided nvm because it was way too slow for me

Resources