How do I uninstall and reinstall Node on macOS? - node.js

nicolasrulli#Nicolas-Rullis-MacBook-Pro / % brew install node
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 55 formulae.
==> Downloading https://ghcr.io/v2/homebrew/core/node/manifests/18.2.0
Already downloaded: /Users/nicolasrulli/Library/Caches/Homebrew/downloads/d3348030d8404d01cc32c085f75250b04ad35d8c17b9c7e5cbb2d1bc3617e697--node-18.2.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/node/blobs/sha256:bc6d55e53035991aaa6d1917f396d2f0cd9e0281e80d1ba79e99211c5e82a
Already downloaded: /Users/nicolasrulli/Library/Caches/Homebrew/downloads/5daf56787ecaf72b3065acd64fff548c38ec43c7572d18b603bc33da86aa53a2--node--18.2.0.monterey.bottle.tar.gz
==> Pouring node--18.2.0.monterey.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/doc/node/gdbinit
/usr/local/share/doc/node is not writable.
You can try again using:
brew link node
Warning: The post-install step did not complete successfully
You can try again using:
brew postinstall node
==> Summary
🍺 /usr/local/Cellar/node/18.2.0: 1,930 files, 49.2MB
==> Running `brew cleanup node`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
nicolasrulli#Nicolas-Rullis-MacBook-Pro / % brew link node
Linking /usr/local/Cellar/node/18.2.0...
Error: Could not symlink share/doc/node/gdbinit
/usr/local/share/doc/node is not writable.
nicolasrulli#Nicolas-Rullis-MacBook-Pro / % brew postinstall node
==> Postinstalling node
Warning: The post-install step did not complete successfully
You can try again using:
brew postinstall node
nicolasrulli#Nicolas-Rullis-MacBook-Pro / %
I ran brew uninstall --force node and that 'worked'. I then ran brew cleanup and it worked also. Next was brew install node. This started to run but then gave errors saying the link command couldn't run. Any advice?

Node.js uninstall command this
brew uninstall --force node
Node.js install
Then you can download the version you want by entering https://nodejs.dev/download. The advice I can give you is to install nvm. In this way, you can use more versions.
I hope it works for you :)

Related

Node gets instantly killed - MacOS

I've been trying to debug why is this happening and how can I fix it so that i can work!
The problem looks like this:
➜ ~ node
[1] 2912 killed node
It happens with yarn and npm so i assumed its node. I cant find any node mention in /var/log/system.log.
I tried reinstalling node via brew but error persists. I reinstalled yarn as well.
What else can I do find out why this is hapening? Where is this being logged to?
BTW: I'm not running out of memory, i have available ram and hard disk space
I opened the "Console" utility app and found this error when i try to start nodejs:
proc 4298: load code signature error 2 for file "node"
Thanks
I had exactly the same issue on new Macos Big Sur and I fixed this problem by following those steps, I hope it will save someone's time:
This is what I was getting
➜ ~ node
[1] 12187 killed node
In the Console I found that error message pointed to icu4c
CODE SIGNING: process 11193[node]: rejecting invalid page at address 0x1047f4000 from offset 0x0 in file "/opt/homebrew/Cellar/icu4c/67.1/lib/libicui18n.67.1.dylib" (cs_mtime:1614412395.998493416 == mtime:1614412395.998493416) (signed:1 validated:1 tainted:1 nx:0 wpmapped:0 dirty:0 depth:0)
so I uninstalled the node and icu4c packages (if you have yarn, you may also want to uninstall it)
➜ ~ brew uninstall node
Uninstalling /opt/homebrew/Cellar/node/15.10.0... (3,390 files, 54.9MB)
➜ ~ brew uninstall icu4c
Uninstalling /opt/homebrew/Cellar/icu4c/67.1... (258 files, 72.4MB)
then I ran one additional command, just to remove anything that's not needed.
brew cleanup
after that I ran brew install node and it started working!
Here's a log from my terminal:
➜ ~ brew install node
==> Downloading https://homebrew.bintray.com/bottles/icu4c-67.1.arm64_big_sur.bo
Already downloaded: /Users/pgoca/Library/Caches/Homebrew/downloads/0ead47d11680c7b6ed4d76eb2a934878314e34e9ac979b5306b6fb7a1ac3f8ae--icu4c-67.1.arm64_big_sur.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/node-15.10.0.arm64_big_sur.
Already downloaded: /Users/pgoca/Library/Caches/Homebrew/downloads/5e38af944729bd333a4217bf8327099595ebec3a5e7c5eb1029399555828e39b--node-15.10.0.arm64_big_sur.bottle.tar.gz
==> Installing dependencies for node: icu4c
==> Installing node dependency: icu4c
==> Pouring icu4c-67.1.arm64_big_sur.bottle.tar.gz
==> Caveats
icu4c is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides libicucore.dylib (but nothing else).
If you need to have icu4c first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/icu4c/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/icu4c/sbin:$PATH"' >> ~/.zshrc
For compilers to find icu4c you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/icu4c/lib"
export CPPFLAGS="-I/opt/homebrew/opt/icu4c/include"
==> Summary
🍺 /opt/homebrew/Cellar/icu4c/67.1: 258 files, 72.4MB
==> Installing node
==> Pouring node-15.10.0.arm64_big_sur.bottle.tar.gz
🍺 /opt/homebrew/Cellar/node/15.10.0: 3,390 files, 54.9MB
==> Caveats
==> icu4c
icu4c is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides libicucore.dylib (but nothing else).
If you need to have icu4c first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/icu4c/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/icu4c/sbin:$PATH"' >> ~/.zshrc
For compilers to find icu4c you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/icu4c/lib"
export CPPFLAGS="-I/opt/homebrew/opt/icu4c/include"
➜ ~ node
Welcome to Node.js v15.10.0.
Type ".help" for more information.
>
FIXED
I fixed by completely removing node and reinstalling via nvm
I am on the M1 Mac Mini. The solution for me was to reinstall Homebrew. Steps:
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)"
brew install node

Can't Install Node 12.8

I have been trying to install node.js on my Mac to use React Native. I tried many different times to install and reinstall node but I'd get a lot of errors.
I have tried installing on a fresh hard drive and I still can't seem to get it to work.
What I would try:
bash-3.2$ brew install node
==> Downloading https://homebrew.bintray.com/bottles/node-12.8.0.mojave.bottle.t
Already downloaded: /Users/malqadi/Library/Caches/Homebrew/downloads/8ea6192c6101b64b58b3ff8bf0cab0b89eb67851ec11f5c95edda2fffcbdbfb0--node-12.8.0.mojave.bottle.tar.gz
==> Pouring node-12.8.0.mojave.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/systemtap/tapset/node.stp
Target /usr/local/share/systemtap/tapset/node.stp
already exists. You may want to remove it:
rm '/usr/local/share/systemtap/tapset/node.stp'
To force the link and overwrite all conflicting files:
brew link --overwrite node
To list all files that would be deleted:
brew link --overwrite --dry-run node
Possible conflicting files are:
/usr/local/share/systemtap/tapset/node.stp
/usr/local/lib/dtrace/node.d
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/node/12.8.0: 4,629 files, 53.1MB
I do what it recommends, but its the same:
bash-3.2$ brew postinstall node
==> Postinstalling node
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`
So I try brew doctor:
bash-3.2$ 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 or file an issue; just ignore this. Thanks!
Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
node
How would I get this to work?
Try removing the npm module with this command:
rm '/usr/local/share/systemtap/tapset/node.stp'
before linking node with this command:
brew link node

installing particular version of node with homebrew is giving error

I neeed to install node version 10 and has followed below steps
brew install node#10
brew link node#10
above command gives error, thus tried
brew link node#10 --force
Now I'm getting error
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/node#10/bin:$PATH"' >> ~/.bash_profile
I've checked .bash_profile and above entry does exist, not getting why above error keeps on showing ?
As commented by #quentin, this is not an error, it is an informational message.
Secondly, I prefer using the package n for installing a specific version of Node. https://www.npmjs.com/package/n
Initially, you get the default version of node installed. And then you use n to play around with the Node versions.
Install n - $ npm install -g n
Installing node 10 - $ n 10
Installing node stable - $ n stable
Installing node latest - $ n latest
Installing node lts - $ n lts
I believe that you are still running an older node version. First, try to uninstall it with brew uninstall node#8 assuming that node 8 is installed.
Then
brew uninstall --ignore-dependencies --force node
brew uninstall --ignore-dependencies --force icu4c
brew install icu4c
brew unlink icu4c && brew link icu4c --force
brew install node#10
I experienced the same problem few days ago and I found tis blog post helpful: Mac Brew Node 10 upgrade

Installing node with brew fails on Mac OS Sierra

I'm trying to install node with homebrew on macOS Sierra.
I run
brew install node
After a seemingly successful install I get the following when trying to run node:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
Abort trap: 6
This is the series of incantations that eventually worked for me based on this link suggested by #robertklep and #vovkasm.
brew uninstall --force node
brew uninstall icu4c && brew install icu4c
brew unlink icu4c && brew link icu4c --force
brew install node
I'm not sure if they're all needed, but given that I can't get my machine in the previous state... I'll just leave this info here, maybe it'll be useful for somebody else.
In my case, brew upgrade node resolve the problem :)
Well I got this error trying to install #angular/cli, realized node might be out of date. Following #mircealungu 's exact steps didn't quite work for me, here is the modified version that worked for me.
brew uninstall --ignore-dependencies --force node
brew uninstall --ignore-dependencies --force icu4c
brew install icu4c
brew unlink icu4c && brew link icu4c --force
brew install node
Upgrading node fixed a problem.
brew upgrade node
I recently encountered a similar issue (after doing
brew switch node 9.8.0 to downgrade to a previous version of node)
dyld: Library not loaded:
/usr/local/opt/icu4c/lib/libicui18n.60.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
Abort trap: 6
The issue is that node is picky about which version of icu4c it's looking for, and the version I had installed (62) was higher than node was expecting.
To fix, I made sure I had version 60 of icu4c selected.
First I found which versions I had with brew info icu4c, then did
brew switch icu4c 60.2 to select the one node was expecting.
For me it was apparently a problem with the icu4c installation from brew.
brew reinstall icu4c
will reinstall icu4c.
if you don't have it installed,
brew install icu4c
Seems file /usr/local/opt/icu4c/lib/libicui18n.58.dylib does not exists in you system.
Please ensure that icu4c installed with Homebrew.
brew info icu4c
If already installed, try reinstall: brew reinstall icu4c
If not installed, try install: brew install icu4c
For high seirra, just "brew upgrade" makes magic!
First I uninstall node and icu4c, force to uninstall all versions
brew uninstall --force --ignore-dependencies node icu4c
After install version 8 of Node
brew install node#8
If it already install, please just upgrade
brew upgrade node#8
And enter
node -v
v8.11.1
This was triggered for me after a brew upgrade and brew update ran. I was able to fix it by simply re-installing the two items flagged as problems (which made sense to me):
brew reinstall node
brew reinstall icu4c
None of the above worked for me. I'm using High Sierra.
What fixed it for me was brew upgrade
I found a solution that works great over here. I'll briefly give the commands below.
First, cd into the homebrew formula directory:
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
Git log:
git log --follow icu4c.rb
Choose the commit hash that matches the version you need. I needed version 61.1, thus chose the 6d9815 commit:
git checkout -b icu4c-61.1 6d9815
Reinstall:
brew reinstall ./icu4c.rb
Switch:
brew switch icu4c 61.1
That fixed it for me.
Credit: hanxue
Nothing worked for me but running this worked
brew link --overwrite node
brew uninstall --force node
brew uninstall --ignore-dependencies icu4c
brew unlink icu4c && brew link icu4c --force
brew install node
This error was given to me after migrating machines.
Even though everything was installed, when I went to check node -v or npm version, I'd get this error.
What fixed it was brew reinstall icu4c.
I had the same problem with my local php installation.
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
Abort trap: 6
Solved the problem with this command. (check your version)
brew link --overwrite --force php#7.1
I removed export PATH="/usr/local/opt/icu4c/bin:$PATH" from my ~/.bash_profile file and it fixed my problem.
My error was:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib
Referenced from: /usr/local/opt/node#10/bin/node
Reason: image not found
Abort trap: 6
My /usr/local/opt/icu4c/lib contains libicui18n.64.dylib
I fixed by
cd /usr/local/Cellar
rm -rf node*/
rm -rf icu4c/
brew install node
it seems like your icu4u Reference path is not set properly
first check you might instal icu4c or not by putting below comment in comment promt
brew info icu4c
or else reinstall
brew reinstall icu4c
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
hope This might help !!!!!
It's as easy as a common software, just download installation package from official site:NodeJS
and then download a recommended version(currently 8.11.3, end with .pkg), install it as a common software, then u can use it. I tried so many methods, and only this works for me.
Try restarting your machine. That helped me.
i run this on macos:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
it takes around 20 minu

Node installed, but not NPM

I installed node with brew 'brew install node', and I get a warning message
'Warning: The post-install step did not complete successfully'.
When I put in node -v, I can indeed see the current version of node, however when I try to find the current version of npm, I get this error.
-bash: /usr/local/bin/npm: No such file or directory
Is the reason that NPM does not exist because the post-install step did not complete successfully ?
Yup, that thing happened to me too. After a lot of searching I came to a solution. I think this would help you.
sudo brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R myusername /usr/local
brew link --overwrite node
sudo brew postinstall node
Thanks!!

Resources