Update Node.js: Error while updating Node.js on Mac - node.js

I am using mac. I have currently installed Node.js 4.4.3
Aleeshas-MacBook-Air:~ aleesha$ node -v
v4.4.3
I want to update Node.js to it's latest version by following these steps.
First I tried to execute: brew update. However, I was getting the below error when I executed the command:
brew update Error: /usr/local is not writable. You should change the
ownership and permissions of /usr/local back to your user account:
sudo chown -R $(whoami) /usr/local
So after searching for solution on Google, I ran this command: sudo chown -R $(whoami) /usr/local
After that I again executed the brew update command. I think it was successfully executed since I didn't see any error message. Last few lines on the command prompt were:
==> Migrating HOMEBREW_REPOSITORY (please wait)...
==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew! Homebrew no longer needs to have ownership of /usr/local.
If you wish you can
return /usr/local to its default ownership with: sudo chown
root:wheel /usr/local Aleeshas-MacBook-Air:~ aleesha$
However after this step when I execute the upgrade command, it failed.
Aleeshas-MacBook-Air:~ aleesha$ brew upgrade node
Error: node not installed
Aleeshas-MacBook-Air:~ aleesha$
I am not sure what exactly needs to be done here.
Thanks
EDIT: Executed brew doctor to check for system anomalies.
Aleeshas-MacBook-Air:~ aleesha$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3-config
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5-config
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5m-config
Warning: No developer tools installed.
Install the Command Line Tools:
xcode-select --install
Warning: Python is installed at /Library/Frameworks/Python.framework
Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/node/android-ifaddrs.h
/usr/local/include/node/ares.h
/usr/local/include/node/ares_version.h
/usr/local/include/node/libplatform/libplatform.h
/usr/local/include/node/nameser.h
/usr/local/include/node/node.h
/usr/local/include/node/node_buffer.h

You didn't install Node using Homebrew, use this gist to uninstall your current installation of Node.
And then:
brew update && brew install node

It seems like you didn't install nodejs through brew. If you installed Node without brew, brew doesn't recognize it. I had the same issue until I realised that I installed Node with Node Version Manager. Make sure you installed it using Brew.
brew list
Will show you the things brew installed.

Related

Can't run node or npm, getting the message "zsh: killed" or "Killed: 9" when running on bash

Not sure if related, but over the weekend I upgraded my OS to Big Sur version 11.1 and then when I began working one thing went wrong after another and now I can't use node or npm at all. I get the following message in zsh:
% node -v
zsh: killed node -v
And the following on bash
node -v
Killed: 9
I've tried to install different versions of node through n, which makes no difference.
How it got this way?
Prior to this issue (after my OS upgrade), I couldn't run npm install, and would get the following message:
Maximum call stack size exceeded
This seems to have been reported on this thread, but as of writing this there are no replies.
As the OP on that thread says, I tried installing npm v7, which initially did solve my problem with the npm install, however caused other issues on the project.
I then decided to use n to install the latest version of node and this caused the errors I have above.
Does anyone know what's going on and how to fix it?
Edit: I was forced to uninstall and reinstall node to be able to go back to work, which did solve it but I am leaving this thread up in case there is a better solution.
TLDR:
brew uninstall git
brew update
brew reinstall pcre2 gettext
brew install git
brew reinstall node
I'm sure there's a more surgical solution (e.g., maybe you don't need brew reinstall pcre2 gettext), but this ^^ worked for me. Below is the path I took:
Skimming some google results, seemed it was at least partly due to the new M1 silicon and the minor MacOS update to 11.2.2. Tried to brew update and got:
Error: Failure while executing; `git config --replace-all homebrew.analyticsmessage true` was terminated by uncaught signal KILL.
Which led me to this: https://github.com/Homebrew/brew/issues/10275#issuecomment-757351887. After doing these uninstall, reinstall, installs, I finished with a brew reinstall node and voilà! Didn't need to uninstall node and install from scratch:
an#As-Air ~ % node -v
v15.11.0
TL;DR
The solution is to reinstall node and all its dependencies. Luckily, Homebrew offers a one-liner all-in-one solution:
brew reinstall $(brew deps node) node
Why?
I had followed #albielin and #Mariusz' solutions without success. I didn't yet want the #bgh's nuclear option to reinstall Homebrew with all its packages.
It seems in my case, the issue wasn't coming from those specific dependencies (pcre2 gettext openssl icu4c), but rather another one. No need to worry about git. But do reinstall all dependencies to be sure and avoid an endless trial-and-error with every one of them.
Had the same issue. Tried #albielin approach but it still didn't work for me. Ive took a look in the console and saw issues with openssl and icu4c when executing node --version and reinstalled both. Now it works.
So in addition to #albielin commands I did:
brew reinstall openssl
brew reinstall icu4c
I had the same issue. The answers above didn't work for me. Looking at the console while running node --version I found the error load code signature error 2 for file "node"
Reinstalling Homebrew as detailed in this Stack Overflow answer did it for me:
Run the official uninstall script: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Clean up: sudo rm -rf /opt/homebrew
Fresh install: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install node: brew install node
The node post-install process ran into a few issues due to symlinks that could not be overwritten. The advice given in this article helped me resolve this; a few sudo chown ... and brew link --overwrite node commands later node was successfully installed!

Why does brew say that nodejs is installed?

First of all, I run node in macOS terminal, and get
bash: /usr/local/bin/node: No such file or directory
I run brew install node and get
Warning: node 12.10.0 is already installed, it's just not linked You can use `brew link node` to link this version.
So I run brew link node and get
Error: Could not symlink include/node/common.gypi
/usr/local/include/node is not writable.
I suppose that's some permission issue. So I run it with sudo and get
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
Then I try brew uninstall node, and repeat all the above steps, and still get the same errors. What do I do?
Note: Never use sudo with brew. Running brew as root may change the owner of brew related files, and make it inaccessible by current user.
Answer for the question: you may have broken the permission of /usr/local/include/node directory already by using sudo. To fix this,
rm -rf /usr/local/include/node
brew unlink node
brew link node
If the above commands don't fix your problem. Try to fix all folder permission under /usr/local recursively. Then try the above fix again.
sudo chown -R $(whoami):admin /usr/local/*
I figured it out. Doing brew link --overwrite node worked.

Unable to link/run Node.js v6 in Homebrew

I'm trying to specifically install Node.js v6, which is proving confusingly difficult.
On a new MacBook running Sierra, I've run:
brew install node#6
This gave me:
Please note by default only English locale support is provided. If you need
full locale support you should either rebuild with full icu:
`brew reinstall node --with-full-icu`
or add full icu data at runtime following:
https://github.com/nodejs/node/wiki/Intl#using-and-customizing-the-small-icu-build
This formula is keg-only, which means it was not symlinked into /usr/local.
This is an alternate version of another formula.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/node#6/bin:$PATH"' >> ~/.zshrc
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/node#6/lib
CPPFLAGS: -I/usr/local/opt/node#6/include
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/node#6/6.9.5: 3,891 files, 41.3M
If I run which node, I get node not found. If I run brew link node, I get Error: No such keg: /usr/local/Cellar/node. I also ran sudo chown -R $USER /usr/local.
How can I "link" Node.js v6 so that other software can find it? Do I run echo 'export PATH="/usr/local/opt/node#6/bin:$PATH"' >> ~/.zshrc? I don't want to run anything I'm not sure of.
Don't use Homebrew to install node.
I like the Node Version Manager (NVM), and there is n (as mentioned by #ntalbs in the comments). These are better options on a Mac for node, to avoid certain. issues. later.
Note, you can install nvm and n via Homebrew. (brew install nvm or brew install n).

Error installing nodejs in arch linux

Okay so i just made a fresh install of nodejs package on archlinux using pacman. Command for the same was
sudo pacman -S nodejs npm . Now when i tried to run the same i am getting error as
node: error while loading shared libraries: libicui18n.so.57: Which pretty much means that libicu is either not there or not the correct version. The problem that i am facing is that it is not there in pacman. I tried
sudo pacman -S libicu, which returned not able to find the package. What is the right way to resolve this issue. FYI : just a note, i would prefer not to install from source and prefer using pacman for the same. If there is any other output that you need to know please comment below and will let you know about the same.
I am currently on manjaro i3 fresh install.
Just found out, The name for package in arch linux is icu and not libicu. Once that is installed node will start working fine.
Update
After using node for quite sometime i realised that a better way to install node is using NVM. It would install both node and npm locally and you get the option to manage multiple version.Installation is as simple as
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
This error is caused by installing node js and npm package modules with missing packages that are unsupported by your system how about you try this:
$ sudo pacman -Rsc -n nodejs
$ sudo pacman -Sy nodejs
$ sudo pacman -Sy npm
did you use testing repo?
If you enabled testing repositories, but later on decided to disable them, you should:
Remove/Comment them from /etc/pacman.conf
pacman -Syuu to "rollback" your updates from these repositories.
The second item is optional, but keep it in mind if you notice any problems.
Also you can install stable ver : pacman -S core/icu
You just need to update arch
sudo pacman -Syu

Node.js not linked error

I've literally searched everything on web. But I could not find the solution for the error node-0.8.8 already installed, it's just not linked. Is it related to a path file issue?
Execute this list of commands in this particular order:
sudo brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) $(brew --prefix)
brew link --overwrite node
brew postinstall node
After you've run brew upgrade to update node to the latest version, run brew doctor to see what potential problems there are. It might tell you that node is unlinked, in which case, running brew link node will link it. (You might need to first run brew unlink node)
I got the same error today and it told me that Node was not properly linked and there were unexpected header files as well.
When I tried to reinstall node, It told me that it was already installed, just not linked.
Warning: /usr/local/include isn't writable
/usr/local/bin/node already exists. Remove it
Solution
To fix this, I took ownership of it by using:
sudo chown -R `whoami` /usr/local/
Then I force linked all files by using:
brew link --overwrite node
After that I did the post install routine with:
brew postinstall node
Then I checked if node was properly installed with:
node -v
I received output v5.1.0 and It was fixed :). Hope this helps.
This may not be the perfect fix out there since I have started dabbling with node and homebrew just 10 minutes ago but it did the job for me.
Your old version of Node 0.5 was probably not installed with Homebrew (or Homebrew's script changed in the large gap between the 0.5 beta releases to the 0.8 stable releases (the 0.6 and 0.7 releases in-between).
Both Homebrew and the official Node installer try to install to /usr/local/bin so I'd recommend starting by simply deleting /usr/local/bin/node, /usr/local/bin/npm, and /usr/local/lib/node and try again.
hardcorepunk's answer worked. However, we can no longer chown /usr/local in High Sierra. So, execute the commands in this order:
sudo brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) $(brew --prefix)/*
brew link --overwrite node
brew postinstall node
To link the node, run following command:
brew link homebrew/versions/node<version no>
And to check whether it is properly installed or not, run:
node -v
If node will get properly linked, it will not through any error, and will print node version. You can read nice explanation about it from here.
For line did the job:
brew link --overwrite node
It forces the link and overwrite all conflicting files:
You can change the permission of the file "/usr/local/bin/node", like "chmod +w /usr/local/bin/node", to make it writable.

Resources