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

5

7

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.

Principle answered 21/12, 2020 at 17:8 Comment(1)
Please check if your system is running out of memory. Do you have configured swap?Oedipus
L
1

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
Letourneau answered 9/3, 2021 at 1:44 Comment(0)
A
1

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.

Affected answered 10/3, 2022 at 3:20 Comment(0)
G
0

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
Gunpoint answered 17/4, 2021 at 12:7 Comment(0)
C
0

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:

  1. Run the official uninstall script: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
  2. Clean up: sudo rm -rf /opt/homebrew
  3. Fresh install: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  4. 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!

Closeup answered 27/6, 2021 at 17:41 Comment(0)
D
0

I was getting this error while running command npm run dev. But when I tried with command npm start, then it started working and I was able to open documentation.

Dixiedixieland answered 6/10, 2023 at 7:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.