Node gets instantly killed - MacOS - node.js

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

Related

How do I uninstall and reinstall Node on macOS?

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 :)

Error: node not installed after updated homebrew on mac M1

After I updated homebrew, I can't use homebrew to upgrade node. It can't find node.
Updated Brew on mac M1
After getting this error
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
brew bundle dump
I updated homebrew using:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" for my mac M1.
Then I followed the instructions for two commands brew said to run.
Then I ran these commands:
$ cd ~
$ brew bundle dump
UPDATE: $ brew bundle dump didn't do what I expected. When I look in /opt/homebrew/bin not all of the contents from /usr/local/bin are there, but I would expect them to move there.
Now Brew can't find node
$ brew upgrade node
Gave me:
Error: node not installed
but $ node -v gives
v12.6.0
And the BrewFile that $ brew bundle dump created shows node: brew "node".
I misunderstood what brew bundle dump does. It only creates a file that says the packages that brew should install.
BrewFile works like a package.json file in node.js. You have to run brew bundle install to install the packages listed in BrewFile.
So my node package was still in the old location usrs/local/bin and node was not in opt/homebrew/bin where it should be.
To fix, I moved the BrewFile into the new brew location opt/homebrew then ran brew bundle install from in that directory. Now node is in the correct place opt/homebrew/bin along with all my other brew packages.
Now which node gives:
/opt/homebrew/bin/node
It looks like this also updated node. But you have to open a new terminal. node -v will then show the newly instaled version. Your old version is still in usrs/local/bin but it looks like the paths corrected for me.

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

Can I link node#6 by force?

Is it ok to link node#6 by force?
$ which node
$ echo $?
1
$ brew link node
Error: No such keg: /usr/local/Cellar/node
$ brew search node
leafnode llnode node node-build node#0.10 node#0.12 node#4 node#5 node#6 ✔ nodebrew nodeenv nodenv
Caskroom/cask/mindnode-pro Caskroom/cask/node-profiler Caskroom/cask/nodebox Caskroom/cask/nodeclipse Caskroom/cask/printnode Caskroom/cask/soundnode
$ brew link node#6
Warning: node#6 is keg-only and must be linked with --force
Note that doing so can interfere with building software.
Edit:
I went ahead and did it:
$ brew link node#6 --force
Linking /usr/local/Cellar/node#6/6.9.5... 7 symlinks created
node and npm work fine now.
Scary warning.
I ran in to the same problem and followed the advice of brew info node#6 and added export PATH="/usr/local/opt/node#6/bin:$PATH to my .bash_profile. All the command line tools worked as expected.
(I've actually removed that line for my .bash_profile now and added an alias to set the path manually when I need it.)
You may (I have) run into some Cellar issues..
What is the output you got from brew doctor?
I had this when executing brew doctor:
Warning: Some keg-only formula are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
brew link <formula> will cause other formulae to detect them during
the ./configure step. This may cause problems when compiling those
other formulae.
I had to execute brew unlink node#6 for it to return 'your system is ready to brew'.

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).

Resources